30 Claude Prompts That Write PowerShell Scripts
Describe the Windows task and Claude returns a runnable, commented PowerShell script you can paste into an elevated prompt. Prompts for files and folders, Active Directory, services and processes, CSV reports, scheduled tasks, and remote management. Not "give me some commands".
In short: This page contains 30 copy-paste ready prompts, organized into 6 categories with a description and pro tip for each. The first 15 prompts are free instantly โ no signup needed. Hand-curated and tested by the AI Academy team.
Files & Folders
5 promptsBulk File Rename Script
1/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a single self-contained PowerShell script that batch-renames files in a folder according to a pattern, so I can run it as-is in an elevated PowerShell prompt. </context> <inputs> - Target folder: [PATH] - Files to match: [E.G. *.jpg, ALL, OR A REGEX] - Rename pattern: [E.G. PREFIX_YYYYMMDD_INDEX, LOWERCASE, REMOVE SPACES] - Include subfolders?: [YES / NO] - Starting index / padding: [E.G. START AT 1, PAD TO 3 DIGITS] </inputs> <task> Write a script using Get-ChildItem and Rename-Item that builds the new name from the pattern, handles name collisions safely, and supports a preview mode. Include a -WhatIf-style dry run switch (param [switch]$DryRun) that prints old-name to new-name mappings without renaming. Add param() block, comment-based help, and inline comments explaining each step. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Never overwrite an existing file silently; skip or suffix collisions and log them. - Wrap risky operations in try/catch and support -WhatIf; no external modules. </constraints> <format> Return the full script in one code block, then a short note on how to run it (dry run first) and how to tweak the pattern. </format>
Produces a safe bulk file-rename script with a dry-run preview and collision handling, ready to run.
Pro tip: Always run it once with -DryRun and paste the mapping output back to Claude to confirm the pattern before the real rename.
Duplicate File Finder & Cleanup
2/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that finds duplicate files by content hash and helps me reclaim space, runnable directly in an elevated prompt. </context> <inputs> - Folder(s) to scan: [ONE OR MORE PATHS] - Match method: [SIZE + SHA256 HASH / NAME + SIZE] - What to do with dupes: [REPORT ONLY / MOVE TO QUARANTINE FOLDER / DELETE ALL BUT NEWEST] - Minimum file size to consider: [E.G. 1MB] - Quarantine folder (if moving): [PATH] </inputs> <task> Write a script that recursively hashes files with Get-FileHash (SHA256), groups by hash, and identifies groups with more than one file. Default to report-only. Add a -Action parameter (Report/Quarantine/Delete) that keeps the newest copy and moves or removes the rest, logging every action. Output a summary of duplicate sets and total reclaimable bytes. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Destructive actions must require an explicit -Action and support -WhatIf; never delete in report mode. - Skip files below the minimum size for speed; handle locked/unreadable files with try/catch. </constraints> <format> Return the full script in one code block, then a short note on running report mode first and reading the reclaimable-space summary. </format>
Generates a content-hash duplicate finder with report, quarantine, and delete modes, ready to run.
Pro tip: Run in Report mode and review the summary before ever passing -Action Delete; quarantine is the safest middle step.
Folder Size & Disk Usage Report
3/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that reports which folders are consuming the most disk space, runnable directly in an elevated prompt. </context> <inputs> - Root path to analyze: [PATH] - Depth to summarize: [E.G. TOP-LEVEL ONLY / 2 LEVELS DEEP] - Sort by: [SIZE DESCENDING] - Top N folders to show: [E.G. 20] - Output: [CONSOLE TABLE / ALSO EXPORT CSV] </inputs> <task> Write a script that walks the tree with Get-ChildItem -Recurse, sums file lengths per folder, and produces a sorted table of the largest folders with size in human-readable units (KB/MB/GB). Include total used space and a percent-of-parent column. Add a switch to also export the results to CSV with a timestamped filename. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Convert bytes to readable units cleanly; handle access-denied folders with try/catch and note them. - No external modules; format the console output with Format-Table. </constraints> <format> Return the full script in one code block, then a short note on interpreting the output and adjusting depth for faster scans. </format>
Creates a disk-usage report that ranks the largest folders with human-readable sizes, ready to run.
Pro tip: Point it at a shallow depth first on huge drives; a full recursive sum of C:\ can take a while.
Timestamped Backup & Archive Script
4/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that backs up a folder into a timestamped compressed archive and prunes old backups, runnable directly in an elevated prompt. </context> <inputs> - Source folder to back up: [PATH] - Destination folder for archives: [PATH] - Archive naming: [E.G. SOURCENAME_YYYYMMDD_HHMMSS.zip] - Retention: [KEEP LAST N BACKUPS OR LAST N DAYS] - Files/folders to exclude: [E.G. *.tmp, node_modules] </inputs> <task> Write a script that uses Compress-Archive to zip the source into a timestamped file in the destination, honoring the exclude list, then deletes backups beyond the retention policy. Log start time, file count, archive size, and any pruned backups. Return a nonzero exit code on failure so it can be scheduled. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Verify the source exists and the destination is writable before starting; fail cleanly with a clear message. - Wrap compression and pruning in try/catch; write a log line to a .log file next to the archives. </constraints> <format> Return the full script in one code block, then a short note on scheduling it and choosing a retention policy. </format>
Produces a timestamped zip-backup script with an exclude list and retention pruning, ready to run.
Pro tip: Pair this with the scheduled-task prompt in the Automation section to run nightly backups hands-free.
Delete Old Files by Age
5/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that cleans up files older than a threshold (logs, temp, downloads), runnable directly in an elevated prompt. </context> <inputs> - Folder to clean: [PATH] - Age threshold: [E.G. OLDER THAN 30 DAYS] - Filter: [ALL / *.log / SPECIFIC EXTENSIONS] - Include subfolders?: [YES / NO] - Also remove empty folders left behind?: [YES / NO] </inputs> <task> Write a script that finds files whose LastWriteTime is older than the threshold, defaults to a preview, and deletes them only when a -Confirm-style -Execute switch is passed. Report count and total size that will be or was freed, and optionally remove empty directories afterward. Log each deletion to a timestamped log file. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Preview by default; require an explicit -Execute switch and support -WhatIf so nothing is deleted accidentally. - Never touch files newer than the threshold; skip locked files with try/catch and log them. </constraints> <format> Return the full script in one code block, then a short note on running preview mode and safely scheduling the cleanup. </format>
Generates an age-based file-cleanup script with a preview-first, explicit-execute safeguard, ready to run.
Pro tip: Test the age threshold in preview mode against a copied folder before running -Execute on a production log directory.
XML tags are just the start. Learn the full Claude workflow.
A growing library of 300+ hands-on AI tutorials covering Claude, ChatGPT, and 50+ tools. New tutorials added every week.
Users & Active Directory
5 promptsBulk AD User Creation from CSV
6/30You are a senior Active Directory administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that creates Active Directory users in bulk from a CSV, runnable on a domain-joined admin machine with the ActiveDirectory module. </context> <inputs> - CSV path and columns: [E.G. FirstName,LastName,Department,Title,Manager] - Target OU distinguished name: [E.G. OU=Staff,DC=corp,DC=local] - UPN suffix / email domain: [E.G. corp.local] - Username convention: [E.G. FIRST INITIAL + LASTNAME, LOWERCASE] - Default groups to add: [E.G. All-Staff, VPN-Users] </inputs> <task> Write a script that imports the CSV, builds a unique sAMAccountName and UserPrincipalName per row (handling collisions), generates a strong random initial password with change-at-next-logon, creates each account with New-ADUser in the target OU, sets department/title/manager, and adds default group memberships. Skip rows that already exist and log every created, skipped, and failed user with the reason. </task> <constraints> - One runnable .ps1 file; requires and imports the ActiveDirectory module (check with #Requires). - Support -WhatIf; validate the OU and CSV exist before processing any row. - Never hardcode a shared password; generate per-user and export credentials to a secured CSV. </constraints> <format> Return the full script in one code block, then a short note on the expected CSV header and how to review the results log. </format>
Produces a bulk AD user-provisioning script from CSV with unique names, groups, and a results log, ready to run.
Pro tip: Run it against a test OU with two sample rows first, then check the exported credentials CSV before doing the full import.
Inactive AD Account Audit & Disable
7/30You are a senior Active Directory administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that finds stale AD accounts and optionally disables them for security hygiene, runnable on a domain-joined admin machine. </context> <inputs> - Inactivity threshold: [E.G. NO LOGON IN 90 DAYS] - Scope: [ENTIRE DOMAIN / SPECIFIC OU DN] - Include: [ENABLED USERS ONLY / ALSO NEVER-LOGGED-IN] - Action: [REPORT ONLY / DISABLE / DISABLE + MOVE TO DISABLED OU] - Disabled-accounts OU (if moving): [DN] </inputs> <task> Write a script that queries users with Get-ADUser and LastLogonTimestamp older than the threshold, defaults to report-only, and outputs a table of name, sAMAccountName, last logon, and OU. When -Action Disable is passed, disable each account with Disable-ADAccount (and optionally move it), appending a note to its description with the date and reason. Export the full audit to a timestamped CSV. </task> <constraints> - One runnable .ps1 file; #Requires the ActiveDirectory module; support -WhatIf. - Default to report-only; only disable when -Action is explicit; exclude service and privileged accounts via an exclusion list parameter. - Note that LastLogonTimestamp is replicated with lag; state this in a comment. </constraints> <format> Return the full script in one code block, then a short note on running the report first and using the exclusion list. </format>
Generates a stale-account audit script that reports and optionally disables inactive AD users, ready to run.
Pro tip: Always run report mode, review the CSV with the account owners, and populate the exclusion list before ever passing -Action Disable.
Bulk Group Membership Manager
8/30You are a senior Active Directory administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that adds or removes users from AD groups in bulk from a CSV, runnable on a domain-joined admin machine. </context> <inputs> - CSV path and columns: [E.G. SamAccountName,GroupName,Action] - Default action if not in CSV: [ADD / REMOVE] - Match users by: [sAMAccountName / UPN / EMAIL] - Behavior if already a member: [SKIP + LOG] - Behavior if user or group missing: [LOG + CONTINUE] </inputs> <task> Write a script that imports the CSV, resolves each user and group, and applies Add-ADGroupMember or Remove-ADGroupMember based on the Action column. Skip no-op changes (already in/out), and record every add, remove, skip, and error with the reason in a results log. Print a summary count at the end (added, removed, skipped, failed). </task> <constraints> - One runnable .ps1 file; #Requires the ActiveDirectory module; support -WhatIf. - Verify each user and group exist before acting; never throw on a single bad row, log and continue. - Confirm removals do not touch protected/built-in groups; block those with a guard list. </constraints> <format> Return the full script in one code block, then a short note on the CSV format and reviewing the summary output. </format>
Creates a CSV-driven group-membership manager that adds and removes AD members with full logging, ready to run.
Pro tip: Include an Action column per row so you can mix adds and removes in one file instead of running two passes.
Password Expiry Notification Script
9/30You are a senior Active Directory administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that emails users whose AD password is about to expire, runnable as a daily scheduled task on a domain-joined machine. </context> <inputs> - Warn when password expires within: [E.G. 7, 3, AND 1 DAYS] - Scope: [DOMAIN / SPECIFIC OU DN] - SMTP server and port: [HOST:PORT] - From address and subject: [FROM, SUBJECT] - Test mode recipient: [YOUR EMAIL FOR DRY RUNS] </inputs> <task> Write a script that finds enabled users with an expiring password using msDS-UserPasswordExpiryTimeComputed, calculates days remaining, and sends a personalized reminder via Send-MailMessage only to those inside the warning windows. Support a -TestMode switch that redirects all mail to the test recipient. Skip accounts set to never expire, and log who was notified and who was skipped. </task> <constraints> - One runnable .ps1 file; #Requires the ActiveDirectory module. - Default to -TestMode so no real users are emailed until verified; guard against sending duplicate emails in one run. - Handle SMTP failures per-user with try/catch and continue; write a summary log line. </constraints> <format> Return the full script in one code block, then a short note on testing with -TestMode and scheduling it to run once each morning. </format>
Produces a password-expiry reminder script that emails affected users with a safe test mode, ready to run.
Pro tip: Keep -TestMode on until you confirm the recipient list and email wording, then schedule it to run every morning.
New-Hire Onboarding Provisioning
10/30You are a senior Active Directory administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that fully provisions a single new hire in one run, so IT can onboard staff consistently from a domain-joined admin machine. </context> <inputs> - New hire details: [FIRST, LAST, TITLE, DEPARTMENT, MANAGER SAM] - Target OU DN: [E.G. OU=Staff,DC=corp,DC=local] - Role/department group mapping: [E.G. SALES -> Sales-Team, CRM-Users] - Home folder / share path (optional): [UNC PATH] - Email domain and notification recipient: [DOMAIN, IT DISTRO] </inputs> <task> Write a script that takes new-hire params, creates the AD user with a unique username and strong temporary password (change at next logon), sets title/department/manager, adds the role-based group memberships from the mapping, optionally creates and permissions a home folder, and emails a provisioning summary (username, temp password securely, groups) to the IT recipient. Log every step and stop with a clear message if any critical step fails. </task> <constraints> - One runnable .ps1 file; #Requires the ActiveDirectory module; support -WhatIf. - Idempotent: if the user already exists, do not overwrite, report and exit. - Never log the plaintext password to the console; deliver it only via the secured summary. </constraints> <format> Return the full script in one code block, then a short note on filling the group mapping and running it per new hire. </format>
Generates an end-to-end new-hire provisioning script covering account, groups, home folder, and IT notice, ready to run.
Pro tip: Define the department-to-groups mapping once at the top so every hire in that team gets an identical, auditable setup.
Services & Processes
5 promptsService Health Monitor & Auto-Restart
11/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that watches critical Windows services and restarts any that stop, runnable on a schedule or as a loop. </context> <inputs> - Services to monitor: [SERVICE NAMES OR DISPLAY NAMES] - Run mode: [ONE-SHOT (FOR SCHEDULER) / CONTINUOUS LOOP] - Check interval (loop mode): [E.G. 60 SECONDS] - On restart failure: [LOG ONLY / ALSO EMAIL OR WRITE EVENT LOG] - Max restart attempts per service: [E.G. 3] </inputs> <task> Write a script that checks each service with Get-Service, and when a service is not Running, attempts Start-Service up to the max attempts with a short backoff. Log every check result, restart attempt, and outcome to a timestamped log and optionally to the Windows event log. In continuous mode, loop on the interval; in one-shot mode, run once and exit for a scheduled task. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; no external modules. - Skip services that are Disabled (do not fight the config); note them in the log. - Wrap each service action in try/catch so one failure does not stop the rest; exit nonzero if any service could not be recovered. </constraints> <format> Return the full script in one code block, then a short note on choosing one-shot vs loop mode and reading the log. </format>
Produces a service watchdog that restarts stopped services with retries and logging, ready to run.
Pro tip: Use one-shot mode with the scheduled-task prompt for lightweight monitoring instead of a script that runs forever.
High-CPU / Runaway Process Killer
12/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that finds processes hogging CPU or memory and can terminate offenders, runnable in an elevated prompt. </context> <inputs> - Threshold: [E.G. CPU > 80% SUSTAINED OR WORKING SET > 2GB] - Sample window: [E.G. AVERAGE OVER 3 SAMPLES, 2 SECONDS APART] - Process allowlist (never kill): [E.G. System, explorer, sqlservr] - Action: [REPORT ONLY / KILL OFFENDERS OVER THRESHOLD] - Top N to display: [E.G. 15] </inputs> <task> Write a script that samples process CPU and memory using Get-Process (and CPU deltas across samples), ranks the top consumers, and prints a table with PID, name, CPU%, and memory. Default to report-only; when -Kill is passed, terminate processes above the threshold with Stop-Process, skipping anything on the allowlist and critical system processes. Log every kill with PID, name, and the measured usage. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; no external modules. - Never kill processes on the allowlist or protected system processes; default to report-only and require an explicit -Kill switch. - Handle access-denied on protected processes gracefully with try/catch. </constraints> <format> Return the full script in one code block, then a short note on tuning the threshold and running report mode before -Kill. </format>
Generates a top-consumers process monitor with an optional, allowlist-guarded kill mode, ready to run.
Pro tip: Populate the allowlist with your database and shell processes first so the -Kill switch can never take down something essential.
Service Start/Stop Orchestrator
13/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that starts or stops a set of related services in the correct dependency order, runnable in an elevated prompt for maintenance windows. </context> <inputs> - Services and order: [ORDERED LIST FOR STARTUP; REVERSE FOR SHUTDOWN] - Operation: [START / STOP / RESTART] - Wait-for-running timeout per service: [E.G. 60 SECONDS] - On a service failing to reach the target state: [ABORT / CONTINUE + LOG] - Confirm before acting?: [YES / NO] </inputs> <task> Write a script that takes an ordered service list and an operation, then starts services in order (or stops them in reverse), waiting until each reaches Running/Stopped or the timeout elapses before moving on. Verify final state with Get-Service, and produce a step-by-step transcript showing each service, the action, wait time, and result. On restart, stop in reverse then start in order. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; support -WhatIf. - Respect the wait timeout; do not proceed to the next service until the current one settles or times out. - Wrap each transition in try/catch; honor the abort-vs-continue setting and exit nonzero if any service failed. </constraints> <format> Return the full script in one code block, then a short note on defining the correct order for a multi-service app. </format>
Creates an ordered service start/stop/restart orchestrator with state waits and a transcript, ready to run.
Pro tip: List dependent services (DB, then app, then web) in startup order once; the script handles the reverse order for clean shutdowns.
Windows Service Inventory
14/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that inventories every Windows service with its config and account, runnable in an elevated prompt for audits. </context> <inputs> - Scope: [LOCAL MACHINE / A LIST OF COMPUTERS] - Fields wanted: [NAME, DISPLAY NAME, STATUS, START TYPE, LOGON ACCOUNT, BINARY PATH] - Filter: [ALL / ONLY NON-MICROSOFT / ONLY RUNNING WITH AUTO START] - Highlight risks: [E.G. RUNNING AS LOCALSYSTEM WITH UNQUOTED PATH] - Output: [CONSOLE TABLE + TIMESTAMPED CSV] </inputs> <task> Write a script that collects service details via Get-CimInstance Win32_Service (name, state, start mode, StartName, PathName), applies the chosen filter, and flags common risks such as unquoted service paths containing spaces and services running under privileged accounts. Print a summary table and export the full inventory to a timestamped CSV. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Use CIM rather than deprecated WMI cmdlets; handle unreachable computers with try/catch when scope is multiple machines. - Clearly mark flagged risks in a dedicated column; no external modules. </constraints> <format> Return the full script in one code block, then a short note on reading the risk flags and extending the field list. </format>
Produces a full service inventory with logon accounts and security-risk flags exported to CSV, ready to run.
Pro tip: Ask it to sort the CSV so unquoted-path and LocalSystem services surface at the top of your audit review.
Process Watcher With Alert
15/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that confirms a required process is running (and alerts if not) or watches for a forbidden process to appear, runnable on a schedule. </context> <inputs> - Mode: [REQUIRE PROCESS RUNNING / ALERT IF PROCESS APPEARS] - Process name(s): [E.G. myapp, agent.exe] - On violation: [WRITE EVENT LOG / EMAIL / RESTART A PROCESS OR SERVICE] - Recovery command (optional): [E.G. START A PATH OR SERVICE] - Run mode: [ONE-SHOT / LOOP WITH INTERVAL] </inputs> <task> Write a script that checks for the target process with Get-Process, evaluates it against the chosen mode, and on a violation triggers the configured alert and optional recovery action (start the process/service or stop the forbidden one). Log every check and every action taken with a timestamp. Support one-shot mode for the scheduler and a loop mode with a configurable interval. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; no external modules. - Distinguish 'not running' from 'access denied'; do not false-alert on permission errors, handle with try/catch. - Make the recovery action optional and idempotent; exit nonzero when a violation could not be resolved. </constraints> <format> Return the full script in one code block, then a short note on choosing the mode and wiring the recovery command. </format>
Generates a process watchdog that alerts or self-heals when a required or forbidden process changes state, ready to run.
Pro tip: Use require-running mode plus a recovery command to auto-relaunch a background agent that keeps crashing overnight.
Reports & CSV Export
5 promptsSystem Inventory Report to CSV
16/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that collects a full hardware and OS inventory for one or many machines and exports it to CSV, runnable in an elevated prompt. </context> <inputs> - Scope: [LOCAL / LIST OF COMPUTER NAMES OR A TXT FILE] - Data to collect: [OS + BUILD, CPU, RAM, SERIAL, MODEL, DISKS, IP, LAST BOOT] - Output folder for the CSV: [PATH] - Filename convention: [E.G. Inventory_YYYYMMDD.csv] - Credential for remote (if needed): [PROMPT / CURRENT USER] </inputs> <task> Write a script that queries each computer with Get-CimInstance (Win32_OperatingSystem, Win32_ComputerSystem, Win32_Processor, Win32_BIOS, Win32_LogicalDisk, network config) and builds one row per machine with the requested fields, converting bytes to GB and formatting last-boot time. Export all rows to a timestamped CSV and print a console summary of successes and failures. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; use CIM sessions for remote queries. - Handle offline or unauthorized machines with try/catch and record them as failed rows, do not abort the whole run. - One consistent object schema so the CSV columns line up across all machines. </constraints> <format> Return the full script in one code block, then a short note on supplying the computer list and opening the CSV in Excel. </format>
Produces a hardware and OS inventory script that exports one clean row per machine to CSV, ready to run.
Pro tip: Feed it a text file of computer names so the same script inventories your whole fleet in one pass.
Disk Space Report With HTML Email
17/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that checks disk free space across servers and emails a formatted HTML report, runnable as a daily scheduled task. </context> <inputs> - Servers to check: [LIST OR TXT FILE] - Warning / critical thresholds: [E.G. WARN < 20%, CRITICAL < 10%] - SMTP server, from, to: [HOST, FROM, RECIPIENTS] - Only email if any drive is below threshold?: [YES / ALWAYS SEND] - Include: [ALL FIXED DRIVES / SPECIFIC LETTERS] </inputs> <task> Write a script that queries logical disks with Get-CimInstance Win32_LogicalDisk (DriveType 3) per server, computes free percent and free GB, and builds an HTML table with rows color-coded green/amber/red against the thresholds. Sort worst-first, add a summary header, and send it with Send-MailMessage as an HTML body. Optionally suppress the email when everything is healthy. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Inline CSS in the HTML so it renders in Outlook; handle unreachable servers as a clearly marked error row. - Wrap SMTP send in try/catch and log the outcome; no external modules. </constraints> <format> Return the full script in one code block, then a short note on setting thresholds and scheduling the daily send. </format>
Generates a color-coded disk-space HTML email report across servers with thresholds, ready to run.
Pro tip: Turn on 'only email if below threshold' so the report becomes a genuine alert instead of daily noise you learn to ignore.
Event Log Export & Filter to CSV
18/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that pulls filtered Windows event log entries and exports them to CSV for troubleshooting or audit, runnable in an elevated prompt. </context> <inputs> - Log(s): [E.G. System, Application, Security] - Levels: [ERROR, WARNING, CRITICAL] - Time range: [E.G. LAST 24 HOURS OR A START/END] - Optional filters: [EVENT IDs, SOURCE/PROVIDER, MESSAGE KEYWORD] - Output CSV path: [PATH] </inputs> <task> Write a script that queries events with Get-WinEvent and a FilterHashtable (log name, level, start time), then applies any extra filters for event ID, provider, or message text. Select TimeCreated, LogName, Level, Id, ProviderName, and a trimmed Message, sort newest-first, and export to a timestamped CSV. Print a count-by-EventID summary to the console. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Prefer Get-WinEvent with FilterHashtable for speed over Get-EventLog; handle 'no events found' cleanly. - Escape/trim multi-line messages so the CSV stays well-formed; no external modules. </constraints> <format> Return the full script in one code block, then a short note on adjusting the time range and event-ID filter. </format>
Creates a fast event-log query-and-export script with flexible filters and a CSV output, ready to run.
Pro tip: Give it the specific Event IDs you are chasing so the CSV stays focused instead of thousands of noise entries.
Installed Software Inventory Export
19/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that lists installed software (with versions) across machines and exports it to CSV for license and audit tracking, runnable in an elevated prompt. </context> <inputs> - Scope: [LOCAL / LIST OF COMPUTERS] - Fields: [NAME, VERSION, PUBLISHER, INSTALL DATE, ARCHITECTURE] - Filter: [ALL / NAME CONTAINS KEYWORD / PUBLISHER] - Output CSV path: [PATH] - Dedupe identical entries?: [YES / NO] </inputs> <task> Write a script that reads installed programs from the uninstall registry keys (both 64-bit and 32-bit hives) rather than the slow Win32_Product class, per machine, and builds a row per product with the requested fields. Apply the filter, optionally dedupe, tag each row with the computer name, and export a timestamped CSV. Print a per-machine count summary. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Read the registry uninstall keys (avoid Win32_Product, which is slow and can trigger repairs); note this in a comment. - For remote scope use Invoke-Command; handle offline machines with try/catch and mark them failed. </constraints> <format> Return the full script in one code block, then a short note on the registry-vs-Win32_Product choice and filtering by publisher. </format>
Produces a fast registry-based installed-software inventory across machines exported to CSV, ready to run.
Pro tip: Filter by a publisher name to quickly build a license count for one vendor across the fleet.
Certificate Expiry Report
20/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that scans local certificate stores for certificates nearing expiry and reports them, runnable as a scheduled audit. </context> <inputs> - Stores to scan: [E.G. LocalMachine\My, LocalMachine\WebHosting] - Warn window: [E.G. EXPIRES WITHIN 30 DAYS] - Scope: [LOCAL / LIST OF SERVERS] - Output: [CONSOLE TABLE + CSV / ALSO EMAIL] - Ignore self-signed / specific issuers?: [OPTIONAL EXCLUSIONS] </inputs> <task> Write a script that enumerates certificates in the chosen stores with Get-ChildItem Cert:\, calculates days-until-expiry, and lists those expiring within the warn window (plus any already expired) with subject, issuer, thumbprint, NotAfter, and days left. Sort by days remaining ascending, apply exclusions, export to a timestamped CSV, and optionally email the summary. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - For remote scope use Invoke-Command against the cert provider; handle unreachable hosts with try/catch. - Clearly separate 'expiring soon' from 'already expired' in the output; no external modules. </constraints> <format> Return the full script in one code block, then a short note on choosing stores and scheduling the weekly report. </format>
Generates a certificate-expiry scanner across stores and servers with a sorted CSV report, ready to run.
Pro tip: Schedule it weekly with a 30-day window so you renew certs long before an outage instead of on the day they expire.
Automation & Scheduled Tasks
5 promptsRegister a Scheduled Task Script
21/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that registers another script as a Windows scheduled task with the right trigger and account, runnable once in an elevated prompt. </context> <inputs> - Script to run and arguments: [PATH + ANY ARGS] - Task name and folder: [NAME, OPTIONAL TASK PATH] - Trigger: [DAILY AT TIME / AT STARTUP / EVERY N MINUTES / AT LOGON] - Run as: [SYSTEM / A SPECIFIC SERVICE ACCOUNT] - Run whether user logged on or not, highest privileges?: [YES / NO] </inputs> <task> Write a script that builds the action (powershell.exe -NoProfile -ExecutionPolicy Bypass -File <script> <args>), the trigger from the chosen schedule, the principal (account and run level), and settings (start-when-available, restart-on-failure), then registers it with Register-ScheduledTask. If a task with that name exists, update it instead of erroring. Print the resulting task's next run time to confirm. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax using the ScheduledTasks module cmdlets. - Use -NoProfile and -ExecutionPolicy Bypass in the action so the task runs consistently; comment why. - Handle an existing task by updating rather than failing; prompt for or accept the service account credential securely. </constraints> <format> Return the full script in one code block, then a short note on verifying the task in Task Scheduler and choosing the run account. </format>
Produces a task-registration script that schedules any .ps1 with the correct trigger and account, ready to run.
Pro tip: Use this to schedule the backup, cleanup, or reporting scripts from the other categories so they run unattended.
Daily Log Rotation & Cleanup Task
22/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that rotates and compresses application log files and purges old ones, designed to run daily as a scheduled task. </context> <inputs> - Log folder(s): [PATH(S)] - Files to rotate: [E.G. *.log] - Rotate when: [SIZE OVER N MB / DAILY REGARDLESS] - Compress rotated logs?: [ZIP / LEAVE PLAIN] - Retention: [DELETE ARCHIVES OLDER THAN N DAYS] </inputs> <task> Write a script that, for each matching log, renames it with a date/time stamp, optionally compresses the rotated copy with Compress-Archive, recreates an empty active log if needed, and deletes archived logs older than the retention period. Write its own run log with counts of rotated, compressed, and purged files, and exit nonzero on failure so the scheduler flags it. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; support -WhatIf. - Do not rotate a file that is exclusively locked, skip and log it; never delete inside the retention window. - Idempotent and safe to run daily; no external modules. </constraints> <format> Return the full script in one code block, then a short note on picking a rotation trigger and scheduling it nightly. </format>
Generates a log rotation and retention script that stamps, compresses, and purges logs, ready to schedule.
Pro tip: Pair it with the scheduled-task prompt and run it just after midnight so each day starts with fresh log files.
Scheduled Backup Task
23/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that performs a scheduled backup of files or a database dump to a target location with verification, designed to run unattended. </context> <inputs> - What to back up: [FOLDER(S) / SQL DUMP COMMAND / FILE LIST] - Destination: [LOCAL PATH / UNC SHARE] - Compression and naming: [ZIP, TIMESTAMP FORMAT] - Retention policy: [KEEP LAST N / N DAYS] - Notify on result: [EMAIL / EVENT LOG / LOG FILE ONLY] </inputs> <task> Write a script that runs the backup (copy or compress the sources, or invoke the provided dump command), writes a timestamped archive to the destination, verifies the archive exists and is non-zero in size, prunes old backups per the retention policy, and sends the chosen success/failure notification. Record duration, size, and status in a run log, and return a nonzero exit code on any failure. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax. - Verify destination reachability and free space before backing up; verify the archive after writing. - Wrap each stage in try/catch; never silently succeed if verification fails; no external modules beyond built-ins. </constraints> <format> Return the full script in one code block, then a short note on plugging in a DB dump command and scheduling it. </format>
Creates a verified, unattended backup script with retention and success/failure notification, ready to schedule.
Pro tip: Because it exits nonzero on failure, configure the scheduled task to email you only when the last run result is not success.
Windows Update Status Report Task
24/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that reports pending and recently installed Windows updates and flags machines missing patches, designed to run on a schedule. </context> <inputs> - Scope: [LOCAL / LIST OF SERVERS] - Report: [PENDING UPDATES / LAST N INSTALLED / BOTH] - Flag if: [PENDING SECURITY UPDATES OR NO UPDATE IN N DAYS] - Output: [CSV / HTML EMAIL] - SMTP details if emailing: [HOST, FROM, TO] </inputs> <task> Write a script that uses the Windows Update COM API (Microsoft.Update.Session / Searcher) to list pending updates and reads recent installs from the update history per machine, then builds a per-machine summary of pending count, last-installed date, and a compliance flag. Export to CSV or send an HTML email highlighting non-compliant machines. Handle machines that need a reboot to finish updates. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; use the Update COM API (no third-party module required). - For remote scope use Invoke-Command; handle unreachable machines and access errors with try/catch as failed rows. - Clearly mark reboot-pending and non-compliant machines; comment the COM calls. </constraints> <format> Return the full script in one code block, then a short note on running it remotely and scheduling a weekly compliance report. </format>
Produces a Windows Update compliance report across machines with pending and installed status, ready to schedule.
Pro tip: Ask it to sort non-compliant and reboot-pending machines to the top so your patch review starts with the riskiest boxes.
Scheduled Folder Sync (Robocopy Wrapper)
25/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that mirrors or syncs a source folder to a destination using Robocopy with proper logging and exit-code handling, designed to run on a schedule. </context> <inputs> - Source and destination: [PATH / UNC] - Mode: [MIRROR (DELETE EXTRAS) / COPY NEW+CHANGED ONLY] - Excludes: [FILES/DIRS TO SKIP] - Multithreading and retries: [E.G. /MT:16, /R:2 /W:5] - Log folder: [PATH] </inputs> <task> Write a script that constructs the Robocopy command from the inputs (mirror vs copy, excludes, threads, retry/wait), runs it, captures its exit code, and translates Robocopy's exit codes into a clear success/warning/failure result (0-7 are success/informational, 8+ are errors). Write a timestamped Robocopy log, print a human-readable summary, and return an exit code the scheduler can act on. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax wrapping robocopy.exe. - Correctly interpret Robocopy exit codes (bit flags); do not treat exit code 1 as a failure. - Guard mirror mode with a confirmation or -Force switch since it deletes; verify source and destination first. </constraints> <format> Return the full script in one code block, then a short note on the exit-code mapping and safely using mirror mode. </format>
Generates a Robocopy sync wrapper with correct exit-code interpretation and logging, ready to schedule.
Pro tip: Test in copy-only mode before enabling mirror; mirror deletes files at the destination that are gone from the source.
Most people use 10% of Claude. Tutorials unlock the rest.
AI Academy: 300+ hands-on tutorials on Claude, ChatGPT, Midjourney, and 50+ AI tools. New tutorials added every week.
Remote Management
5 promptsRun a Command on Many Remote Machines
26/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that runs a command or script block against many remote machines in parallel and collects the results, runnable from an admin workstation. </context> <inputs> - Target machines: [LIST OR TXT FILE OF NAMES] - Command or script block to run: [E.G. GET A REGISTRY VALUE, CHECK A SERVICE] - Credential: [CURRENT USER / PROMPT FOR ADMIN CREDS] - Parallelism / throttle limit: [E.G. 20] - Output: [CONSOLE TABLE + CSV] </inputs> <task> Write a script that reads the target list, opens sessions with Invoke-Command -ComputerName (using a throttle limit), runs the provided script block remotely, and returns one result object per machine tagged with the computer name and a success flag. Aggregate reachable and unreachable machines, print a summary table, and export the combined results to a timestamped CSV. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; assumes WinRM/PS Remoting is enabled. - Handle offline hosts and remoting errors with try/catch per machine so one failure never stops the batch. - Support a -ThrottleLimit and pass credentials with Get-Credential when prompted; never hardcode passwords. </constraints> <format> Return the full script in one code block, then a short note on enabling PS Remoting and supplying the machine list. </format>
Produces a parallel remote-execution script that runs a script block fleet-wide and collects results to CSV, ready to run.
Pro tip: Test your script block against one machine first; a bad block failing on 200 servers wastes a lot of time.
Remote Software Deployment
27/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that silently installs or updates an application on a list of remote machines and verifies the result, runnable from an admin workstation. </context> <inputs> - Installer source: [UNC PATH TO MSI/EXE] - Silent install arguments: [E.G. /qn /norestart FOR MSI] - Target machines: [LIST OR TXT FILE] - Detection check: [REGISTRY KEY / FILE VERSION / SERVICE THAT SHOULD EXIST AFTER] - Credential and throttle: [PROMPT / THROTTLE LIMIT] </inputs> <task> Write a script that, per remote machine via Invoke-Command, copies or references the installer from the UNC source, runs the silent install with the given arguments, captures the installer exit code, and then runs the detection check to confirm success. Skip machines that already pass the detection check, and report per machine: skipped, installed, or failed (with exit code or error). Export a deployment CSV. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; assumes PS Remoting is enabled. - Treat MSI exit code 3010 as success-pending-reboot, not failure; verify with the detection check, not just the exit code. - Handle offline machines and install timeouts with try/catch per host; never hardcode credentials. </constraints> <format> Return the full script in one code block, then a short note on setting silent args per installer type and reading the deployment report. </format>
Generates a remote silent-install deployment script with detection-based verification and a per-machine report, ready to run.
Pro tip: Deploy to a small pilot group first and confirm the detection check flips to installed before pushing to the whole fleet.
Restart a Service Across Servers
28/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that restarts a named service across many servers and confirms it came back healthy, runnable from an admin workstation during maintenance. </context> <inputs> - Service name: [SERVICE OR DISPLAY NAME] - Target servers: [LIST OR TXT FILE] - Rollout style: [ALL AT ONCE / ONE AT A TIME (ROLLING)] - Health check after restart: [SERVICE RUNNING / A URL OR PORT RESPONDS] - Credential and throttle: [PROMPT / THROTTLE LIMIT] </inputs> <task> Write a script that, per server via Invoke-Command, stops and starts (or Restart-Service) the target service, waits for it to reach Running, then runs the post-restart health check. In rolling mode, process servers one at a time and stop the rollout if a server fails its health check. Report per server: restarted+healthy, restarted+unhealthy, or failed. Export the results to CSV. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; assumes PS Remoting is enabled; support -WhatIf. - In rolling mode, abort remaining servers on the first unhealthy result and report clearly which ones were untouched. - Handle offline servers and service-not-found with try/catch per host; never hardcode credentials. </constraints> <format> Return the full script in one code block, then a short note on choosing rolling vs all-at-once and defining the health check. </format>
Creates a fleet-wide service restart script with rolling rollout and post-restart health checks, ready to run.
Pro tip: Use rolling mode for anything load-balanced so a bad restart halts the rollout instead of taking every node down at once.
Collect Logs From Remote Servers
29/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that gathers specific log files or event-log exports from many remote servers into one local folder for troubleshooting, runnable from an admin workstation. </context> <inputs> - Target servers: [LIST OR TXT FILE] - What to collect: [FILE PATHS/GLOBS ON EACH SERVER / EVENT-LOG QUERY] - Time window (for event logs): [E.G. LAST 24 HOURS] - Local collection folder: [PATH] - Credential and throttle: [PROMPT / THROTTLE LIMIT] </inputs> <task> Write a script that, per server, either copies matching log files back over an admin share or UNC path, or runs a Get-WinEvent query via Invoke-Command and exports the results, saving everything under a per-server subfolder in the local collection folder (named by server and timestamp). Report per server what was collected or why it failed, and zip the whole collection at the end for easy sharing. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; assumes PS Remoting and/or admin share access. - Keep each server's output in its own subfolder to avoid filename collisions; handle offline servers with try/catch. - Do not overwrite a previous collection; timestamp the root folder; never hardcode credentials. </constraints> <format> Return the full script in one code block, then a short note on choosing file-copy vs event-log mode and where the zip lands. </format>
Produces a remote log-collection script that gathers files or event exports into a timestamped, zipped bundle, ready to run.
Pro tip: Use the event-log mode with a tight time window when chasing an incident so you pull only the relevant window from every server.
Remote Reboot & Health Check Orchestration
30/30You are a senior Windows systems administrator and PowerShell automation engineer. <context> I need a self-contained PowerShell script that reboots a set of remote servers safely, waits for them to come back, and verifies health, runnable during a maintenance window. </context> <inputs> - Target servers: [LIST OR TXT FILE] - Rollout: [ALL AT ONCE / ROLLING ONE AT A TIME] - Pre-reboot check: [E.G. NO ACTIVE USERS / A SERVICE IS DRAINED] - Post-reboot health check: [PING + WINRM + KEY SERVICE RUNNING] - Wait timeout per server: [E.G. 10 MINUTES] </inputs> <task> Write a script that, per server, runs the pre-reboot check, issues Restart-Computer (with -Wait / -For WinRM where useful), polls until the server responds to ping and WinRM within the timeout, then confirms the key service is Running. In rolling mode, do one server fully before the next and stop on the first failure. Report per server: rebooted+healthy, timed out, or failed pre-check, and export a summary CSV. </task> <constraints> - One runnable .ps1 file; valid PowerShell 5.1+ syntax; assumes PS Remoting is enabled; support -WhatIf. - Respect the wait timeout and never assume success just because the reboot command returned; verify with the health check. - In rolling mode, halt remaining servers on the first failure and list which were left untouched; handle offline hosts with try/catch. </constraints> <format> Return the full script in one code block, then a short note on setting the pre-reboot drain check and choosing rolling mode. </format>
Generates a safe remote-reboot orchestrator with pre-checks, wait-for-online polling, and health verification, ready to run.
Pro tip: Always use rolling mode with a real health check in production so one server that fails to come back stops the whole maintenance run.
Frequently Asked Questions
Prompts are the starting line. Tutorials are the finish.
A growing library of 300+ hands-on tutorials on ChatGPT, Claude, Midjourney, and 50+ AI tools. New tutorials added every week.
7-day free trial. Cancel anytime.