Using PSScriptAnalyzer

…for those of you that use Sapiens’ PowerShell Studio, there is a new feature available since version 5.2.118 that allows you to use PSScriptAnalyzer in the GUI. PSScriptAnalyzer is a module that you can run against your scripts and identify any code that is not in line with best practices. As with most code analysis tools, you can add\modify\exclude\remove rules based on your specific requirements.

The official post is here, including instructions on how to install and use the tool: https://www.sapien.com/blog/2016/05/11/use-psscriptanalyzer-in-powershell-studio/

PSScriptAnalyzer direct download: https://www.powershellgallery.com/packages/PSScriptAnalyzer/1.5.0

You can run PSScriptAnalyzer from the command-line as well. Here is an example:

PSScriptAnalyzer-Command-line

…and here is the output from PSScriptAnalyzer to the console:

PSScriptAnalyzer-Output

You can edit the rules to ignore the rules that you do not want analyzed against your code. Just update your code and rerun the analyzer to view the updated output.

Views – 539