ipIterPrompt

PowerShell Script to Move Disabled AD Users to Specific OU

Turn any AI chat into a powershell script to move disabled ad users to specific ou with this community persona prompt.

dark.valerik.spb@gmail.com · awesome-chatgpt-promptsUpdated 2026-05-122,940 copies

PowerShell Script to Move Disabled AD Users to Specific OU is a community-contributed prompt from awesome-chatgpt-prompts (CC0). Copy it, fill in any variables, and paste it into your favorite AI chat to get started immediately.

The prompt

Act as a System Administrator. You are tasked with managing user accounts in Active Directory (AD). Your task is to create a PowerShell script that:

- Identifies all disabled user accounts in the AD.
- Moves these accounts to a designated Organizational Unit (OU) specified by the variable ${targetOU}.

Rules:
- Ensure that the script is efficient and handles errors gracefully.
- Include comments in the script to explain each section.

Example PowerShell Script:
```
# Define the target OU
$targetOU = "OU=DisabledUsers,DC=yourdomain,DC=com"

# Get 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): $_"
    }
}
```
Variables:
- ${targetOU} - The distinguished name of the target Organizational Unit where disabled users will be moved.

Run this prompt on a real model without leaving the page. Every run is saved to your history for this prompt.

How to use

  1. 1Copy the prompt as-is — no variables required.
  2. 2Paste it into ChatGPT, Claude, Gemini, or any capable model.
  3. 3Iterate: follow up with corrections or extra context to refine the output.

Related

Cascading Failure Simulator

Turn any AI chat into a cascading failure simulator with this community persona prompt.

624 copiesOpen ↗

Bibliographic Review Writing Assistant

Turn any AI chat into a bibliographic review writing assistant with this community persona prompt.

2,411 copiesOpen ↗

PowerShell Script for Managing Disabled AD Users

Turn any AI chat into a powershell script for managing disabled ad users with this community persona prompt.

3,533 copiesOpen ↗

Python Code Generator — Clean, Optimized & Production-Ready

Turn any AI chat into a python code generator — clean, optimized & production-ready with this community persona prompt.

1,285 copiesOpen ↗