You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gets the script analyzer rules on the local computer.
19
-
You can select rules by Name, Severity, Source, or SourceType, or even particular words in the rule description.
20
22
21
-
Use this cmdlet to create collections of rules to include and exclude when running the Invoke-ScriptAnalyzer cmdlet.
23
+
Gets the script analyzer rules on the local computer. You can select rules by Name, Severity,
24
+
Source, or SourceType, or even particular words in the rule description.
22
25
23
-
To get information about the rules, see the value of the Description property of each rule.
26
+
Use this cmdlet to create collections of rules to include and exclude when running the
27
+
`Invoke-ScriptAnalyzer` cmdlet.
24
28
25
-
The PSScriptAnalyzer module tests the Windows PowerShell code in a script, module, or DSC resource to determine whether, and to what extent, it fulfils best practice standards.
29
+
To get information about the rules, see the value of the Description property of each rule.
26
30
27
-
PSScriptAnalyzer is an open-source project.
28
-
For more information about PSScriptAnalyzer, to contribute or file an issue, see GitHub.com\PowerShell\PSScriptAnalyzer.
31
+
The PSScriptAnalyzer module tests the PowerShell code in a script, module, or DSC resource to
32
+
determine if it fulfils best practice standards.
29
33
30
34
## EXAMPLES
31
35
32
-
### -------------------------- EXAMPLE 1 --------------------------
33
-
```
36
+
### EXAMPLE 1 - Get all Script Analyzer rules on the local computer
37
+
38
+
```powershell
34
39
Get-ScriptAnalyzerRule
35
40
```
36
41
37
-
This command gets all Script Analyzer rules on the local computer.
42
+
### EXAMPLE 2 - Gets only rules with the Error severity
38
43
39
-
### -------------------------- EXAMPLE 2 --------------------------
40
-
```
44
+
```powershell
41
45
Get-ScriptAnalyzerRule -Severity Error
42
46
```
43
47
44
-
This command gets only rules with the Error severity.
45
-
46
-
### -------------------------- EXAMPLE 3 --------------------------
47
-
```
48
-
$DSCError = Get-ScriptAnalyzerRule -Severity Error | Where SourceName -eq PSDSC
48
+
### EXAMPLE 3 - Run only the DSC rules with the Error severity
This example runs only the DSC rules with the Error severity on the files in the MyDSCModule module.
59
+
Using the **IncludeRule** parameter of `Invoke-ScriptAnalyzerRule` is more efficient than using its
60
+
**Severity** parameter, which is applied only after using all rules to analyze all module files.
56
61
57
-
Using the IncludeRule parameter of Invoke-ScriptAnalyzerRule is much more efficient than using its Severity parameter, which is applied only after using all rules to analyze all module files.
62
+
### EXAMPLE 4 - Get rules by name and severity
58
63
59
-
### -------------------------- EXAMPLE 4 --------------------------
60
-
```
64
+
This example gets rules with "Parameter" or "Alias" in the name that generate an Error or Warning.
65
+
You can use this set of rules to test the parameters of your script or module.
This command gets the standard rules and the rules in the VeryStrictRules and ExtremelyStrictRules modules.
73
-
The command uses the RecurseCustomRulePath parameter to get rules defined in subdirectories of the matching paths.
74
-
75
81
## PARAMETERS
76
82
77
83
### -CustomRulePath
78
-
Gets the Script Analyzer rules in the specified path in addition to the standard Script Analyzer rules.
79
-
By default, PSScriptAnalyzer gets only the standard rules specified in the Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll file in the module.
80
84
81
-
Enter the path to a .NET assembly or module that contains Script Analyzer rules.
82
-
You can enter only one value, but wildcards are supported.
83
-
To get rules in subdirectories of the path, use the RecurseCustomRulePath parameter.
85
+
By default, PSScriptAnalyzer gets only the standard rules specified in the
86
+
`Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll` file in the module. Use this
87
+
parameter to get the custom Script Analyzer rules in the specified path and the standard Script
88
+
Analyzer rules.
84
89
85
-
You can create custom rules by using a custom .NET assembly or a Windows PowerShell module, such as the Community Analyzer Rules in
0 commit comments