February 2019
Intermediate to advanced
626 pages
15h 51m
English
Custom rules may be used with the CustomRulePath parameter. If the two rules were saved in a Rules.psm1 file, they can be used as follows:
$script = @'function Get-CurrentProcess { [CmdletBinding()] param ( ) begin { } process { } end { # # Get the current process # Get-Process -Id $PID }}'@Invoke-ScriptAnalyzer -ScriptDefinition $script -CustomRulePath .\Rules.psm1The script analyzer will show each triggered rule, as follows:
RuleName Severity ScriptName Line Message-------- -------- ---------- ---- -------PSAvoidEmptyComments Information 9 Empty comment.PSAvoidEmptyComments Information 11 Empty comment.PSAvoidEmptyNamedBlocks Warning 5 Empty Begin block.PSAvoidEmptyNamedBlocks Warning 6 Empty Process block.
The script ...
Read now
Unlock full access