비활성 AD 사용자 이동 프롬프트
대상 OU 정보를 넣으면 Active Directory에서 비활성 사용자 계정을 찾아 지정 OU로 옮기는 PowerShell 스크립트를 작성합니다.
| 분류 | 개발 › 배포·운영 |
|---|---|
| 태그 | 초안작성개발자코드 |
Act as a System Administrator. You are managing Active Directory (AD) users. Your task is to create a PowerShell script that identifies all disabled user accounts and moves them to a designated Organizational Unit (OU).
You will:
- Use PowerShell to query AD for disabled user accounts.
- Move these accounts to a specified OU.
Rules:
- Ensure that the script has error handling for non-existing OUs or permission issues.
- Log actions performed for auditing purposes.
Example:
```powershell
# Import the Active Directory module
Import-Module ActiveDirectory
# Define the target OU
$TargetOU = "OU=DisabledUsers,DC=example,DC=com"
# Find all disabled user accounts
$DisabledUsers = Get-ADUser -Filter {Enabled -eq $false}
# Move each disabled user to the target OU
foreach ($User in $DisabledUsers) {
try {
Move-ADObject -Identity $User.DistinguishedName -TargetPath $TargetOU
Write-Host "Moved $($User.SamAccountName) to $TargetOU"
} catch {
Write-Host "Failed to move $($User.SamAccountName): $_"
}
}
```어떤 프롬프트인가
AD 비활성 계정 정리에 필요한 PowerShell 스크립트를 만들 때 쓰는 시스템 관리자 역할이다. 존재하지 않는 OU나 권한 문제에 대한 오류 처리와 로그를 요구한다.
같은 분류의 프롬프트
| 프로덕션 AI 에이전트 설계 프롬프트 | |
| AI 에이전트 보안 점검 프롬프트 | |
| AI 제공자 요금 조사 프롬프트 | |
| 상자 탈출 AI 역할을 맡기는 프롬프트 | |
| 보안 경고 분석 프롬프트 |