Scripting Tips & Tricks: The PowerShell Script Analyzer Module
I love this new module. It makes adhering to scripting recommended practices an absolute doddle.
And there's no need to go and download it from a repository as it comes bundled with v5!
Unleash the Beast
Let's have a look at the cmdlets that come with the psscriptanalyzer module:
Now, run Invoke-ScriptAnalyzer against one of my more popular scripts:
Seems I need replace my Write-Host statement with Write-Output!
Now, let's have a look at the rules used to analyse scripts:
Notice we have DSC rules here, too. Here's a snippet of the standard cmdlet output:
Here, we have Severity and Source. We also have a very useful Description property.
Finally, to get the latest version of the module run Update-Module with psscriptanalyzer supplied to the name parameter, as Administrator.
Update-Module -Name PsScriptAnalyzer