February 2019
Intermediate to advanced
626 pages
15h 51m
English
It is rarely realistic to expect any significant piece of code to pass all of the tests that PSScriptAnalyzer will throw at it.
Individual tests can be suppressed at the function, script, or class level. The following demonstrative function creates a PSCustomObject:
function New-Message {
[CmdletBinding()]
param (
$Message
)
[PSCustomObject]@{
Name = 1
Value = $Message
}
}
Running PSScriptAnalyzer against a file containing the function will show the following warning:
PS> Invoke-ScriptAnalyzer -Path .\New-Message.ps1 | Format-ListRuleName : PSUseShouldProcessForStateChangingFunctionsSeverity : WarningLine : 1Column : 10Message : Function 'New-Message' has verb that could change system state. Therefore, the function has ...
Read now
Unlock full access