Home › Browse

Write a shell/PowerShell script: how to do it with AI

Last checked 2026-10-15

BeginnerBot with human review 🛠️ IT ops & DevOps

Generate and explain admin scripts before running them.

1. Bot automation level

Bot with human review The bot does the work, but facts, numbers or code should be checked.

2. Before you hand it to the bot

3. Copy-paste prompts

Main prompt
Write a PowerShell 7 script that <goal>. Environment: <AD/Entra/etc>. Include -WhatIf support, logging to a file, error handling, and explain each line. Don't use deprecated modules.
Beginner-friendly
Write a PowerShell 7 script that <goal>. Environment: <AD/Entra/etc>. Include -WhatIf support, logging to a file, error handling, and explain each line. Don't use deprecated modules.

I'm new to this: explain each step in plain words and ask me for anything you need before starting.
Check-your-work
Write a PowerShell 7 script that <goal>. Environment: <AD/Entra/etc>. Include -WhatIf support, logging to a file, error handling, and explain each line. Don't use deprecated modules.

When you finish, list any assumptions you made, anything you're unsure about, and what I should double-check before using the result.

Free tiers that can handle this (verified): ChatGPT (incl. Work & Codex), GitHub Copilot, Mistral Le Chat. Others: check plan.

4. Step-by-step

  1. State OS, shell version, environment (AD, Entra, Linux distro) and exact goal.
  2. Ask for the script plus a line-by-line explanation and a dry-run/-WhatIf mode.
  3. Read every command that modifies or deletes something.
  4. Run in a test VM or with -WhatIf first; check output.
  5. Add logging and error handling, then run for real with least-privilege credentials.

5. Which bots and plans can do it

ToolWhat's different herePlan limitsSource
Claude (incl. Claude Code)Claude Code can run and iterate scripts in your terminal with approval.Claude Code and Research need Pro or higher; computer use is Pro/Max only (research preview).code.claude.com/docs/en/desktop
ChatGPT (incl. Work & Codex)Codex can run commands locally; chat can explain scripts.Free tier has limited deep research, Codex and Work; scheduled tasks need Go or higher (per chatgpt.com/pricing).help.openai.com/en/articles/20001275-chatgpt-work-and-codex
CursorAgent runs terminal commands and monitors output.Pricing page unverified; cloud agents require a connected source-control repo.cursor.com/docs/agent/overview
GitHub CopilotCopilot CLI and IDE chat help write and explain scripts.Free: 2,000 completions + 50 chats; cloud agent listed on paid plans.docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent
Mistral Le Chat—Free tier has limited messages, searches and coding sessions; Pro raises limits.mistral.ai/pricing
DeepSeek—Chat app limits not documented officially; API is pay-per-token.api-docs.deepseek.com/quick_start/pricing

Free or paid?

6. Risks and what to double-check

Professions that use this

IT admin / sysadmin

Related tasks

Open in the interactive app