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
The `Invoke-Formatter` cmdlet takes a string parameter named `ScriptDefinition` and formats it according to the input settings parameter `Settings`. If no `Settings` parameter is provided, the cmdlet assumes the default code formatting settings as defined in `Settings/CodeFormatting.psd`.
18
+
The Invoke-Formatter cmdlet takes a string parameter named ScriptDefinition and formats it according to the input settings parameter Settings. If no Settings parameter is provided, the cmdlet assumes the default code formatting settings as defined in Settings/CodeFormatting.psd1.
Invoke-ScriptAnalyzer evaluates a script or module based on a collection of best practice rules and returns objects
28
-
that represent rule violations.
29
-
In each evaluation, you can run all rules or use the IncludeRule and ExcludeRule
30
-
parameters to run only selected rules.
31
-
Invoke-ScriptAnalyzer includes special rules to analyze DSC resources.
32
-
33
-
Invoke-ScriptAnalyzer evaluates only .ps1 and .psm1 files.
34
-
If you specify a path with multiple file types, the .ps1 and
35
-
.psm1 files are tested; all other file types are ignored.
27
+
Invoke-ScriptAnalyzer evaluates a script or module files (.ps1, .psm1 and .psd1 files) based on a collection of best practice rules and returns objects
28
+
that represent rule violations. It also includes special rules to analyze DSC resources.
36
29
30
+
In each evaluation, you can run either all rules or just a specific set using the -IncludeRule parameter and also exclude rules using the -ExcludeRule parameter.
37
31
Invoke-ScriptAnalyzer comes with a set of built-in rules, but you can also use customized rules that you write in
38
-
Windows PowerShell scripts, or compile in assemblies by using C#.
39
-
Just as with the built-in rules, you can add the
40
-
ExcludeRule and IncludeRule parameters to your Invoke-ScriptAnalyzer command to exclude or include custom rules.
32
+
Windows PowerShell scripts, or compile in assemblies by using C#. This is possible by using the -CustomRulePath parameter and it will then only run those custom rules, if the built-in rules should still be run, then also specify the -IncludeDefaultRules parameter. Custom rules are also supported together with the -IncludeRule and -ExcludeRule parameters. To include multiple custom rules, the -RecurseCustomRulePath parameter can be used.
41
33
42
34
To analyze your script or module, begin by using the Get-ScriptAnalyzerRule cmdlet to examine and select the rules you
43
35
want to include and/or exclude from the evaluation.
44
36
45
37
You can also include a rule in the analysis, but suppress the output of that rule for selected functions or scripts.
46
38
This feature should be used only when absolutely necessary.
47
-
To get rules that were suppressed, run
48
-
Invoke-ScriptAnalyzer with the SuppressedOnly parameter.
49
-
For instructions on suppressing a rule, see the description of
50
-
the SuppressedOnly parameter.
51
-
For usage in CI systems, the -EnableExit exits the shell with an exit code equal to the number of error records.
39
+
To get rules that were suppressed, run Invoke-ScriptAnalyzer with the -SuppressedOnly parameter.
40
+
For instructions on suppressing a rule, see the description of the SuppressedOnly parameter.
52
41
53
-
The PSScriptAnalyzer module tests the Windows PowerShell code in a script, module, or DSC resource to determine
54
-
whether, and to what extent, it fulfils best practice standards.
42
+
For usage in CI systems, the -EnableExit exits the shell with an exit code equal to the number of error records.
55
43
56
44
PSScriptAnalyzer is an open-source project.
57
45
For more information about PSScriptAnalyzer, to contribute or file an issue, see GitHub.com\PowerShell\PSScriptAnalyzer.
Fixes certain warnings which contain a fix in their DiagnosticRecord.
403
384
404
-
When you used Fix, Invoke-ScriptAnalyzer runs as usual but will apply the fixes before running the analysis. Please make sure that you have a backup of your files when using this switch. It tries to preserve the file encoding but there are still some cases where the encoding can change.
385
+
When you used Fix, Invoke-ScriptAnalyzer runs as usual but will apply the fixes before running the analysis.
386
+
Please make sure that you have a backup of your files when using this switch.
387
+
It tries to preserve the file encoding but there are still some cases where the encoding can change.
405
388
406
389
```yaml
407
390
Type: SwitchParameter
@@ -450,12 +433,16 @@ File path that contains user profile or hash table for ScriptAnalyzer
450
433
451
434
Runs Invoke-ScriptAnalyzer with the parameters and values specified in a Script Analyzer profile file or hash table
452
435
453
-
If the path, the file's or hashtable's content are invalid, it is ignored. The parameters and values in the profile take precedence over the same parameter and values specified at the command line.
436
+
If the path, the file's or hashtable's content are invalid, it is ignored.
437
+
The parameters and values in the profile take precedence over the same parameter and values specified at the command line.
454
438
455
439
A Script Analyzer profile file is a text file that contains a hash table with one or more of the following keys:
456
440
-- Severity
457
441
-- IncludeRules
458
442
-- ExcludeRules
443
+
-- Rules
444
+
-- CustomRulePath
445
+
-- IncludeDefaultRules
459
446
460
447
The keys and values in the profile are interpreted as if they were standard parameters and parameter values of Invoke-ScriptAnalyzer.
Whenever Invoke-ScriptAnalyzer (isa) is run on a script having the dynamic keyword "Import-DSCResource -ModuleName <somemodule>", if <somemodule> is not present in any of the PSModulePath, isa gives parse error. This error is caused by the powershell parser not being able to find the symbol for <somemodule>. If isa finds the module on PowerShell Gallery (www.powershellgallery.com) then it downloads the missing module to a temp path. The temp path is then added to PSModulePath only for duration of the scan. The temp location can be found in $LOCALAPPDATA/PSScriptAnalyzer/TempModuleDir.
503
+
Whenever Invoke-ScriptAnalyzer is run on a script having the dynamic keyword "Import-DSCResource -ModuleName <somemodule>", if <somemodule> is not present in any of the PSModulePath, Invoke-ScriptAnalyzer gives parse error. This error is caused by the powershell parser not being able to find the symbol for <somemodule>. If Invoke-ScriptAnalyzer finds the module in the PowerShell Gallery (www.powershellgallery.com) then it downloads the missing module to a temp path. The temp path is then added to PSModulePath only for duration of the scan. The temp location can be found in $LOCALAPPDATA/PSScriptAnalyzer/TempModuleDir.
0 commit comments