AeroTools
Home AI Prompts PowerShell Script for Managing...

PowerShell Script for Managing Disabled AD Users

chatgpt • writing content • 17 uses
Free
What is this prompt for?

Puts the model in editing mode rather than writing mode: it cuts the padding and tightens the sentences, leaving the meaning alone.

What it actually does: Act as a System Administrator. You are managing Active Directory (AD) users.

Main use cases:
  • Summarising long documents without losing the meaning
  • Building a clear outline before you start writing
  • Editing text and improving its tone and rhythm
Benefits and results:
  • A steady voice that reflects a clear identity
  • Time saved on first drafts
  • Sharper writing, so readers ask fewer questions
Prompt length: 146 words Reading time: ~1 min Best with: Claude Pro (recommended for writing), ChatGPT Plus, Gemini Advanced

Prompt

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): $_"
    }
}
```

Related Prompts

AeroTools

AeroAssistant

Online AI
Hello! I am your official AeroTools AI Assistant. How can I help you use our tools today?