Lint PowerShell With PSScriptAnalyzer

Detect risky patterns and style problems before code review.

WindowsautomationdeveloperpowershelllintLow risk
Run Invoke-ScriptAnalyzer -Path . -Recurse to list rule violations.

01Command

Command
$ Invoke-ScriptAnalyzer -Path . -Recurse

02What it does

PSScriptAnalyzer applies rules for security, correctness and style, such as avoiding Invoke-Expression and using approved verbs. Running it recursively returns findings that CI can fail on, which is far more consistent than manual review and is naturally a command-line task.

03Risk

RiskLow risk
RequirementsInstall-Module PSScriptAnalyzer -Scope CurrentUser
!Warning: Treat analyzer output as guidance; legitimate code sometimes needs a documented rule suppression.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • PSScriptAnalyzer overview
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Static analysis module that flags rule violations in PowerShell code.

Last verified: 2026-10-13 · Category: Developer

06Related solutions