| description | ms.date | title |
|---|---|---|
This article explains the purpose of the PSScriptAnalyzer module. |
01/28/2026 |
PSScriptAnalyzer module |
PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzer checks the quality of PowerShell code by running a set of rules. The rules are based on PowerShell best practices identified by PowerShell Team and the community. It generates DiagnosticResults (errors and warnings) to inform users about potential code defects and suggests possible solutions for improvements.
PSScriptAnalyzer ships with a collection of built-in rules that check various aspects of PowerShell code such as:
- The presence of uninitialized variables
- Use of PSCredential type
- Use of
Invoke-Expression - And many more
You can choose the rules to include or exclude for your modules and scripts. PSScriptAnalyzer can also fix the formatting of your code. Formatting helps you produce code that conforms to a standard style that is more maintainable and easier to read.
Supported PowerShell Versions and Platforms
- Windows PowerShell 5.1 or greater
- PowerShell 7.2.11 or greater on Windows/Linux/macOS
Install using PowerShellGet 2.x:
Install-Module -Name PSScriptAnalyzer -ForceInstall using PSResourceGet 1.x:
Install-PSResource -Name PSScriptAnalyzer -ReinstallThe -Force or -Reinstall parameters are only necessary when you have an older version of
PSScriptAnalyzer installed. These parameters also work even when you don't have a previous version
installed.