Page 1 of 1

PSScriptAnalyzer - Built in functions

Posted: Mon Jul 25, 2016 7:23 am
by bmclain
Product, version and build: Powershell Studio 2016 - Version: 5.2.124
32 or 64 bit version of product: 64
Operating system: Windows 10
32 or 64 bit OS: 64
PowerShell Version: 5.1 Build 14393

We are using PSScriptAnalyzer on all our scripts and are working to get them error and warning free. We have noticed there are numerous warnings (PSUseApprovedVerbs, PSAvoidUsingEmptyCatchBlock) that get generated from the integrated code. Looks like you ignore those with your builtin integration, but we are getting our scripts scanned during check-in by our Jenkins server. Is there a plan to get these corrected?

Re: PSScriptAnalyzer - Built in functions

Posted: Mon Jul 25, 2016 8:33 am
by davidc
Yes, we are aware the PSScriptAnalyzer warnings and are reviewing if they warrant any changes. The pre-generated code predates PSScriptAnalyzer and we are careful about making any major changes because of compatibility issues that may occur.

Something to keep in mind: Just because you get a PSScriptAnaylzer warning, it doesn't necessarily mean your script is incorrect. The warnings are often suggestions that are applied generally, but there are exceptions where the use is warranted. You will have to decide on a case by case basis.

Re: PSScriptAnalyzer - Built in functions

Posted: Mon Jul 25, 2016 11:41 am
by bmclain
I know it's not incorrect code, it's just not following best practice. We have some pretty stringent requirements around our scripts and don't want to have to keep manually updating the exported script each time. We can get around most of it, but the calls to the forms are something we haven't been able to address any other way.