PSScriptAnalyzer module: setup and commands
Documentation: Microsoft Learn
Run Invoke-ScriptAnalyzer with explicit rules and settings, separate style findings from correctness issues and suppress rules only with a reason.
Getting it
Install-PSResource -Name PSScriptAnalyzer from the PowerShell Gallery. The PowerShell editor extensions bundle it, so a copy may already be present.
Examples
Show reference output
Show reference output
What it is for
Run it before review so the mechanical findings never reach a human reader. It also gives a team something concrete to standardize on, since a settings file can select or suppress individual rules.
Typical tasks
- Scan a repository for rule violations
- Enforce approved verbs and naming
- Catch plain text password parameters
- Fail a build on Error severity findings
- Reformat files to a shared style
- Suppress a rule with a written justification
Check the installed version
Compare the module path and version with the session used by your scheduled task or automation account. Run it before review so the mechanical findings never reach a human reader. It also gives a team something concrete to standardize on, since a settings file can select or suppress individual rules.