PSRAFSCAN DOCUMENTATION
Review AI-Generated PowerShell
Define the task, save the original, scan generated PowerShell, make focused revisions, review the diff, rescan, and test when appropriate.
1. Define the goal
Write down what the script should do, its inputs and outputs, allowed side effects, required privileges, dependencies, and an observable success condition.
2. Save the original response
Keep an unchanged copy of the complete response. Copy only the PowerShell into a separate candidate file; Markdown fences and surrounding prose do not belong in the script.
3. Scan the candidate
Fix syntax errors first, then read each finding in the context of the stated goal.
$scan = @{
Path = './candidate.ps1'
IntendedUse = 'Ps1File'
FailOn = 'Warning'
OutputFormat = 'Json'
OutputPath = './candidate.psrafscan.json'
NonInteractive = $true
}
Invoke-PSRafScan @scan4. Make a focused revision
Change the smallest part that addresses the finding while preserving the required behavior. When another service is involved, share only the source and report details your data policy allows.
5. Review the diff
- Confirm every changed line supports the stated task.
- Look for new commands, dependencies, privileges, paths, network access, or side effects.
- Keep the original and the revision as separate files or versions.
6. Rescan and test when appropriate
Run the same PSRafScan command again and review the complete report. If the revision is understood, test it with known inputs, minimal privileges, and an environment suited to its effects.