Powershell - PSScriptAnalyzer Microsoft tool to verify code meets best practises

PSScriptAnalyzer is a PowerShell module created by Microsoft to be used as a litmus test to figure out if PowerShell code meets certain best practices. It contains various rules that have been created by Microsoft and the open source community as an attempt to ensure all code meets a certain defined standard. If you're wondering how "good" your PowerShell code is, PSScriptAnalyzer is a great tool to use.

PSScriptAnalyzer can be downloaded from the PowerShell Gallery by using the Install-Module command


Install-Module -Name PSScriptAnalyzer

It has only two commands:

Get-ScriptAnalyzerRule 
Invoke-ScriptAnalyzer

Invoke-ScriptAnalyzer -Path C:script_name.ps1



If you have more than a single script to test, Invoke-ScriptAnalyzer can also be pointed at entire folders and can recursively check each script inside.

If you want to go deeper on this tool usage you can review this Microsoft article too:

https://blogs.technet.microsoft.com/heyscriptingguy/2017/01/31/psscriptanalyzer-deep-dive-part-1-of-4/

Download:

https://www.powershellgallery.com/packages/PSScriptAnalyzer/1.11.1

720check