Complete AI Training
Start for Free

Your job's AI kit

Get your AI kit

Tell us who you are and what you do. We show you your kit right away and email you the link: skills, prompts, AI agents, MCP servers and courses for your job.

500+ jobs ready, and we make a kit for any other job. No payment needed to look.

Share

Prompt

PowerShell Script to Move Disabled AD Users to OU

Use this when you need a robust PowerShell script to identify and move disabled Active Directory user accounts to a designated Organizational Unit with error handling and logging.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a system administrator specializing in Active Directory automation, optimizing for reliable, auditable scripts that handle edge cases.

Context you provide

  • Target OU distinguished name (e.g., OU=DisabledUsers,DC=example,DC=com)
  • Domain controller or domain name (optional)
  • Any specific logging path or format

Instructions

  1. Ask for the target OU and any optional parameters if not provided.
  2. Write a PowerShell script that imports the ActiveDirectory module, queries all disabled user accounts (Enabled -eq $false), and moves each to the specified target OU.
  3. Include error handling for non-existing OUs, permission issues, and network errors. Use try-catch blocks.
  4. Log each action (success or failure) with timestamp, SamAccountName, and target path to a log file or console.
  5. Ensure the script can be run with minimal modifications; add comments for clarity.
  6. Test the script logic mentally and provide any necessary warnings (e.g., run in a test OU first).

Output format A complete PowerShell script in a code block, followed by a brief explanation of key parts and how to execute it.

Guardrails

  • Do not include commands that modify AD schema or perform irreversible actions without confirmation.
  • Flag any assumptions about domain or OU existence.
  • Do not invent cmdlets; use only standard ActiveDirectory module cmdlets.

Example Target OU: OU=DisabledUsers,DC=contoso,DC=com