PowerShell script prompt to automate Windows tasks

Get a safe, commented PowerShell script for a repetitive Windows or admin task, with a dry-run mode, logging, error handling and test steps.

Published
Works with
ChatGPT, Claude and Gemini
Level
Intermediate
By
GoodAIPromt editorial team

PowerShell can automate file clean-ups, user reports and server checks in minutes, but a script copied from a forum can just as quickly delete the wrong folder. This PowerShell ChatGPT prompt asks for a script built the careful way: parameters instead of hard-coded paths, a -WhatIf dry run, logging and clear error handling, plus instructions for testing it before it touches anything real.

The prompt

You are a senior Windows systems administrator who writes safe, readable PowerShell.

Task to automate: 
Environment: PowerShell  on , run  by 
Inputs: 
Expected output: 
Modules available: 

Requirements:
1. Use a param() block with validation for all inputs; no hard-coded paths.
2. Support -WhatIf and -Confirm (SupportsShouldProcess) for anything that changes or deletes data.
3. Use try/catch with -ErrorAction Stop, and write a timestamped log to .
4. Use approved verbs and comment-based help (synopsis, parameters, examples).
5. Avoid aliases; write full cmdlet names for readability.
6. Return objects, then export, rather than building text output.

After the script, give:
- A plain-English explanation of what each section does.
- How to test it safely (dry run, test folder, sample data).
- How to schedule it with Task Scheduler, including the execution policy and account to use.
- Any risks or edge cases (long paths, locked files, permissions).

0 of 9 blanks filled

How to use it

  1. Describe the task precisely, including what counts as success.
  2. Run the script with -WhatIf on test data and read the log before using real paths.
  3. Store the script in version control and note who owns it.

Tips

  • Ask for a rollback step if the script moves or renames files.
  • Never paste real passwords into the prompt; use a credential store or prompt at runtime.

Frequently asked questions

What does this prompt do?

Get a safe, commented PowerShell script for a repetitive Windows or admin task, with a dry-run mode, logging, error handling and test steps.

Which AI tools does it work with?

It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.

What do I need to fill in?

9 blanks: describe the task, e.g. move files older than 90 days from a share to an archive folder and report sizes; version, e.g. 5.1 / 7.x; windows 11 / windows server 2022; manually / as a scheduled task; user type and permissions; paths, csv files, ad groups, etc.; and more. Click each blue blank on the page, type your details and press Copy prompt.

Is this prompt free to use?

Yes. You can copy and use it for personal and commercial work.

powershellautomationwindowsscripting

More prompts for ChatGPT, Claude, Gemini.