Before you start
Capture the current state, preserve recoverable data and record recent changes before remediation. Use production-impacting commands only within an approved maintenance or change window.
Define the task precisely
Specify inputs, outputs, targets, permissions, exclusions, error handling, logging and rollback. State PowerShell and module versions.
Generate reviewable code
Request parameters, validation, error handling, logging and WhatIf support where appropriate. Never include passwords, tokens or private keys in prompts.
Review every command
Verify cmdlets and parameters against official documentation and the installed module version. Inspect destructive commands and assumptions about paths, permissions and interactive sessions.
Test safely
Start in a lab or limited target set. Capture before-and-after state and compare expected output. Use Pester for reusable functions when appropriate.
Productionize
Use version control, peer review, least privilege, logging, change control and rollback. Treat AI output as code requiring normal engineering review.
Syntax validation
$tokens=$null;$errors=$null;[System.Management.Automation.Language.Parser]::ParseFile('.\script.ps1',[ref]$tokens,[ref]$errors);$errorsModule versions
Get-Module -ListAvailable | Sort-Object Name,VersionTroubleshooting validation
- Confirm the original symptom is resolved.
- Verify dependent services and application health.
- Review logs or command output for secondary errors.
- Document the root cause and corrective action.
- Retain rollback evidence until the change is accepted.
Frequently Asked Questions
What should I check first?
Capture the current state, exact error, affected scope and recent changes before making changes. Then test the failing layer from the lowest dependency upward.
How do I validate the fix?
Repeat the original failing operation, check dependent services and confirm the issue remains resolved after any required restart or service recovery.
Can this troubleshooting be automated?
Automate read-only diagnostics first. Add remediation only after commands, permissions, logging and rollback behavior have been validated.