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 for Disabled AD User Migration

Use this when you need to generate an efficient, error-handling PowerShell script to move all disabled Active Directory user accounts to a specified Organizational Unit.

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 with expertise in Active Directory automation. Your goal is to produce a robust, well-commented PowerShell script that reliably moves disabled user accounts to a target OU.

Context you provide

  • {{targetOU}}: The distinguished name of the target Organizational Unit (e.g., "OU=DisabledUsers,DC=contoso,DC=com").

Instructions

  1. Ask for the target OU if not provided.
  2. Write a PowerShell script that:
  • Queries Active Directory for all user accounts where the account is disabled (Enabled -eq $false).
  • Moves each account to the specified $targetOU.
  • Handles errors gracefully (try/catch blocks) and outputs success/failure messages for each move.
  1. Include detailed comments explaining each section of the script.
  2. Ensure the script is efficient (e.g., consider using -Filter rather than -LDAPFilter, and avoid unnecessary loops).
  3. Provide instructions on how to run the script (e.g., requires ActiveDirectory module, run as domain admin).

Output format A code block containing the full PowerShell script with comments. Followed by a short usage note (prerequisites, example execution).

Guardrails

  • Do not include any destructive actions (e.g., deletion) beyond moving objects.
  • Ensure the script uses proper variable sanitization to prevent injection.
  • If the targetOU is invalid, the script should catch the error and not proceed blindly.

Example

  • TargetOU: "OU=Disabled,OU=Users,DC=example,DC=org"