22 about_PSScriptAnalyzer
33
44SHORT DESCRIPTION
5- PSScriptAnalyzer is a static code checker for PowerShell modules and scripts .
5+ PSScriptAnalyzer is a static code checker for PowerShell script .
66
77LONG DESCRIPTION
8- PSScriptAnalyzer checks the quality of Windows PowerShell code by running a
9- set of rules. The rules are based on PowerShell best practices identified by
8+ PSScriptAnalyzer checks the quality of Windows PowerShell script by evaluating
9+ that script against a set of rules. The script can be in the form of a
10+ stand-alone script (.ps1 files), a module (.psm1, .psd1 and .ps1 files) or
11+ a DSC Resource (.psm1, .psd1 and .ps1 files).
12+
13+ The rules are based on PowerShell best practices identified by the
1014 PowerShell Team and the community. These rules can help you create more
1115 readable, maintainable and reliable scripts. PSScriptAnalyzer generates
12- DiagnosticResults (errors and warnings) to inform users about potential code
13- defects and suggests possible solutions for improvements.
16+ DiagnosticResults (errors and warnings) to inform you about potential script
17+ issues, including the reason why there might be an issue, and provide you
18+ with guidance on how to fix the issue.
1419
15- PSScriptAnalyzer is shipped with a collection of built-in rules that checks
20+ PSScriptAnalyzer is shipped with a collection of built-in rules that check
1621 various aspects of PowerShell code such as presence of uninitialized
17- variables, usage of PSCredential Type, usage of Invoke-Expression etc.
18- Additional functionalities such as exclude/include specific rules are also
19- supported.
22+ variables, usage of the PSCredential Type, usage of Invoke-Expression, etc.
23+
24+ The following additional functionality is also supported:
25+
26+ * Including and/or excluding specific rules globally
27+ * Suppression of rules within script
28+ * Creation of custom rules
29+ * Creation of loggers
2030
2131RUNNING SCRIPT ANALYZER
2232
@@ -35,7 +45,7 @@ RUNNING SCRIPT ANALYZER
3545
3646 PS C:\> Invoke-ScriptAnalyzer -Path myscript.ps1
3747
38- That will analyze your script against every built-in rule. As you may find
48+ This will analyze your script against every built-in rule. As you may find
3949 if your script is sufficiently large, that could result in a lot of warnings
4050 and/or errors. See the next section on recommendations for running against
4151 an existing script, module or DSC resource.
@@ -106,7 +116,7 @@ RUNNING SCRIPT ANALYZER ON AN EXISTING SCRIPT, MODULE OR DSC RESOURCE
106116 are likely to generate prodigious amounts of output. While these rules have
107117 their reason for being many existing scripts violate these rules over and
108118 over again. It would be a shame if you let a flood of warnings from these two
109- rules, dissuade you from looking at potentially more serious warnings.
119+ rules, keep you from addressing more potentially serious warnings.
110120
111121 There may be other rules that generate a lot of output that you don't care
112122 about - at least not yet. As you examine the remaining diagnostics output,
@@ -130,21 +140,21 @@ RUNNING SCRIPT ANALYZER ON AN EXISTING SCRIPT, MODULE OR DSC RESOURCE
130140 3 PSPossibleIncorrectComparisonWithNull
131141 1 PSAvoidUsingComputerNameHardcoded
132142
133- I may decide to exclude the PSAvoidUsingInvokeExpression rule for the moment
143+ You may decide to exclude the PSAvoidUsingInvokeExpression rule for the moment
134144 and focus on the rest, especially the PSUseDeclaredVarsMoreThanAssigments,
135145 PSAvoidUninitializedVariable and PSPossibleIncorrectComparisonWithNull rules.
136146
137147 As you fix rules, go back and enable more rules as you have time to address
138148 the associated issues. In some cases, you may want to suppress a rule at
139- the function, script or class scope instead of globally excluding rule. See
140- the RULE SUPPRESSION section below.
141-
142- While getting a completely clean run through every rule is a
143- noble goal, it may not always be feasible. You have to weigh the gain of
144- passing the rule and eliminating a "potential" issue with changing script
145- and possibly introducing a new problem. In the end, for existing scripts,
146- it is usually best to have evaluated the rule violations that you deem the
147- most valuable to address.
149+ the function, script or class scope instead of globally excluding the rule.
150+ See the RULE SUPPRESSION section below.
151+
152+ While getting a completely clean run through every rule is a noble goal, it
153+ may not always be feasible. You have to weigh the gain of passing the rule
154+ and eliminating a "potential" issue with changing script and possibly
155+ introducing a new problem. In the end, for existing scripts, it is usually
156+ best to have evaluated the rule violations that you deem the most valuable to
157+ address.
148158
149159RULE SUPPRESSSION
150160
@@ -198,4 +208,3 @@ SEE ALSO
198208 Invoke-ScriptAnalyzer
199209 Set-StrictMode
200210 about_Pester
201-
0 commit comments