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
- Gather inputs: the text, file or details the bot needs.
- Access: make sure you can use the chosen bot/plan (see limits below).
- Context: tell the bot audience, purpose, constraints and examples of good output.
- Privacy check: remove personal, confidential or regulated data unless your plan/workspace is approved for it.
- Success criteria: write down what 'done' looks like (length, format, tests passing, fields filled).
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
- State OS, shell version, environment (AD, Entra, Linux distro) and exact goal.
- Ask for the script plus a line-by-line explanation and a dry-run/-WhatIf mode.
- Read every command that modifies or deletes something.
- Run in a test VM or with -WhatIf first; check output.
- Add logging and error handling, then run for real with least-privilege credentials.
5. Which bots and plans can do it
| Tool | What's different here | Plan limits | Source |
|---|---|---|---|
| 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 |
| Cursor | Agent runs terminal commands and monitors output. | Pricing page unverified; cloud agents require a connected source-control repo. | cursor.com/docs/agent/overview |
| GitHub Copilot | Copilot 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?
- Claude (incl. Claude Code): Free plan: yes. chat, web search, files & code execution, Artifacts, connectors. Claude Code and Research need Pro. Paid: the lowest price we could verify on the official pricing page is $20/month (other plans may exist). For this task, check the plan.
- ChatGPT (incl. Work & Codex): Free plan: yes. unlimited text chats; limited uploads, images, voice, deep research and Codex. Paid: price not verified, so check the official site. Its free tier can handle this task.
- Cursor: Free: not verified, so check the official site. Paid: price not verified, so check the official site. For this task, check the plan.
- GitHub Copilot: Free plan: yes. 2,000 completions and 50 chat requests a month; agent mode and CLI. Paid: the lowest price we could verify on the official pricing page is $10/month (other plans may exist). Its free tier can handle this task.
- Mistral Le Chat: Free plan: yes. limited messages, searches, coding sessions and basic images. Paid: the lowest price we could verify on the official pricing page is $14.99/month (other plans may exist). Its free tier can handle this task.
- DeepSeek: Free: not verified, so check the official site. Paid: price not verified, so check the official site. For this task, check the plan.
6. Risks and what to double-check
- Scripts can reference cmdlets or flags that don't exist in your version — test first.
- Never paste real passwords, tokens or tenant secrets into a chat.
- Test scripts in a non-production environment first; least-privilege credentials.
- AI can hallucinate facts — verify anything that matters.
- Don't share secrets or other people's personal data.