diff --git a/Tests/Engine/ModuleHelp.Tests.ps1 b/Tests/Engine/ModuleHelp.Tests.ps1 index c866bc179..39ff83f2b 100644 --- a/Tests/Engine/ModuleHelp.Tests.ps1 +++ b/Tests/Engine/ModuleHelp.Tests.ps1 @@ -115,11 +115,6 @@ Describe "Cmdlet help" { It "gets example code from " -TestCases $testCases { ($Help.Examples.Example | Select-Object -First 1).Code | Should -Not -BeNullOrEmpty } - - # Should be at least one example description - It "gets example help from $commandName" -TestCases $testCases { - ($Help.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty - } } Describe 'Cmdlet parameter help' { diff --git a/docs/Cmdlets/Get-ScriptAnalyzerRule.md b/docs/Cmdlets/Get-ScriptAnalyzerRule.md index 285529e73..cc7035b2e 100644 --- a/docs/Cmdlets/Get-ScriptAnalyzerRule.md +++ b/docs/Cmdlets/Get-ScriptAnalyzerRule.md @@ -1,89 +1,99 @@ ---- +--- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml +Module Name: PSScriptAnalyzer +ms.date: 10/07/2021 +online version: https://docs.microsoft.com/powershell/module/psscriptanalyzer/get-scriptanalyzerrule?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 --- # Get-ScriptAnalyzerRule + ## SYNOPSIS Gets the script analyzer rules on the local computer. ## SYNTAX ``` -Get-ScriptAnalyzerRule [-CustomRulePath ] [-RecurseCustomRulePath] [-Name ] - [-Severity ] +Get-ScriptAnalyzerRule [[-Name] ] [-CustomRulePath ] [-RecurseCustomRulePath] + [-Severity ] [] ``` ## DESCRIPTION -Gets the script analyzer rules on the local computer. -You can select rules by Name, Severity, Source, or SourceType, or even particular words in the rule description. -Use this cmdlet to create collections of rules to include and exclude when running the Invoke-ScriptAnalyzer cmdlet. +Gets the script analyzer rules on the local computer. You can select rules by Name, Severity, +Source, or SourceType, or even particular words in the rule description. -To get information about the rules, see the value of the Description property of each rule. +Use this cmdlet to create collections of rules to include and exclude when running the +`Invoke-ScriptAnalyzer` cmdlet. -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. +To get information about the rules, see the value of the Description property of each rule. -PSScriptAnalyzer is an open-source project. -For more information about PSScriptAnalyzer, to contribute or file an issue, see GitHub.com\PowerShell\PSScriptAnalyzer. +The PSScriptAnalyzer module tests the PowerShell code in a script, module, or DSC resource to +determine if it fulfils best practice standards. ## EXAMPLES -### -------------------------- EXAMPLE 1 -------------------------- -``` +### EXAMPLE 1 - Get all Script Analyzer rules on the local computer + +```powershell Get-ScriptAnalyzerRule ``` -This command gets all Script Analyzer rules on the local computer. +### EXAMPLE 2 - Gets only rules with the Error severity -### -------------------------- EXAMPLE 2 -------------------------- -``` +```powershell Get-ScriptAnalyzerRule -Severity Error ``` -This command gets only rules with the Error severity. - -### -------------------------- EXAMPLE 3 -------------------------- -``` -$DSCError = Get-ScriptAnalyzerRule -Severity Error | Where SourceName -eq PSDSC +### EXAMPLE 3 - Run only the DSC rules with the Error severity -PS C:\>$Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule\*" +This example runs only the DSC rules with the Error severity on the files in the **MyDSCModule** +module. -PS C:\> Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse +```powershell +$DSCError = Get-ScriptAnalyzerRule -Severity Error | Where-Object SourceName -eq PSDSC +$Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule\*" +Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse ``` -This example runs only the DSC rules with the Error severity on the files in the MyDSCModule module. +Using the **IncludeRule** parameter of `Invoke-ScriptAnalyzerRule` is more efficient than using its +**Severity** parameter, which is applied only after using all rules to analyze all module files. -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. +### EXAMPLE 4 - Get rules by name and severity -### -------------------------- EXAMPLE 4 -------------------------- -``` +This example gets rules with "Parameter" or "Alias" in the name that generate an Error or Warning. +You can use this set of rules to test the parameters of your script or module. + +```powershell $TestParameters = Get-ScriptAnalyzerRule -Severity Error, Warning -Name *Parameter*, *Alias* ``` -This command gets rules with "Parameter" or "Alias" in the name that generate an Error or Warning. -Use this set of rules to test the parameters of your script or module. +### EXAMPLE 5 - Get custom rules -### -------------------------- EXAMPLE 5 -------------------------- -``` +This example gets the standard rules and the rules in the **VeryStrictRules** and +**ExtremelyStrictRules** modules. The command uses the **RecurseCustomRulePath** parameter to get +rules defined in subdirectories of the matching paths. + +```powershell Get-ScriptAnalyzerRule -CustomRulePath $home\Documents\WindowsPowerShell\Modules\*StrictRules -RecurseCustomRulePath ``` -This command gets the standard rules and the rules in the VeryStrictRules and ExtremelyStrictRules modules. -The command uses the RecurseCustomRulePath parameter to get rules defined in subdirectories of the matching paths. - ## PARAMETERS ### -CustomRulePath -Gets the Script Analyzer rules in the specified path in addition to the standard Script Analyzer rules. -By default, PSScriptAnalyzer gets only the standard rules specified in the Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll file in the module. -Enter the path to a .NET assembly or module that contains Script Analyzer rules. -You can enter only one value, but wildcards are supported. -To get rules in subdirectories of the path, use the RecurseCustomRulePath parameter. +By default, PSScriptAnalyzer gets only the standard rules specified in the +`Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll` file in the module. Use this +parameter to get the custom Script Analyzer rules in the specified path and the standard Script +Analyzer rules. -You can create custom rules by using a custom .NET assembly or a Windows PowerShell module, such as the Community Analyzer Rules in -https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Tests/Engine/CommunityAnalyzerRules/CommunityAnalyzerRules.psm1. +Enter the path to a .NET assembly or module that contains Script Analyzer rules. You can enter only +one value, but wildcards are supported. To get rules in subdirectories of the path, use the +**RecurseCustomRulePath** parameter. + +You can create custom rules by using a custom .NET assembly or a PowerShell module, such as the +[Community Analyzer Rules](https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Tests/Engine/CommunityAnalyzerRules/CommunityAnalyzerRules.psm1) +in the GitHub repository. ```yaml Type: String[] @@ -92,50 +102,52 @@ Aliases: CustomizedRulePath Required: False Position: Named -Default value: The rules in Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll. +Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` -### -RecurseCustomRulePath -Searches the CustomRulePath location recursively to add rules defined in files in subdirectories of the path. -By default, Get-ScriptAnalyzerRule adds only the custom rules in the specified path. +### -Name + +Gets only rules with the specified names or name patterns. Wildcards are supported. If you list +multiple names or patterns, it gets all rules that match any of the name patterns. ```yaml -Type: SwitchParameter +Type: String[] Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: +Default value: All rules Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` -### -Name -Gets only rules with the specified names or name patterns. -Wildcards are supported. -If you list multiple names or patterns, it gets rules that match any of the name patterns, as though the name patterns were joined by an OR. +### -RecurseCustomRulePath -By default, Get-ScriptAnalyzerRule gets all rules. +Searches the **CustomRulePath** location recursively to add rules defined in files in subdirectories +of the path. By default, `Get-ScriptAnalyzerRule` adds only the custom rules in the specified path. ```yaml -Type: String[] +Type: SwitchParameter Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: All rules +Default value: False Accept pipeline input: False -Accept wildcard characters: True +Accept wildcard characters: False ``` ### -Severity -Gets only rules with the specified severity values. -Valid values are Information, Warning, and Error. -By default, Get-ScriptAnalyzerRule gets all rules. + +Gets only rules with the specified severity values. Valid values are: + +- Information +- Warning +- Error ```yaml Type: String[] @@ -149,20 +161,29 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### None + You cannot pipe input to this cmdlet. ## OUTPUTS ### Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.RuleInfo -The RuleInfo object is a custom object created especially for Script Analyzer. It is not documented on MSDN. + +The **RuleInfo** object is a custom object created specifically for Script Analyzer. ## NOTES ## RELATED LINKS -[Invoke-ScriptAnalyzer]() +[Invoke-ScriptAnalyzer](Invoke-ScriptAnalyzer.md) [PSScriptAnalyzer on GitHub](https://github.com/PowerShell/PSScriptAnalyzer) diff --git a/docs/Cmdlets/Invoke-Formatter.md b/docs/Cmdlets/Invoke-Formatter.md index acbacc091..c66830adb 100644 --- a/docs/Cmdlets/Invoke-Formatter.md +++ b/docs/Cmdlets/Invoke-Formatter.md @@ -1,26 +1,34 @@ ---- +--- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml +Module Name: PSScriptAnalyzer +ms.date: 10/07/2021 +online version: https://docs.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 --- # Invoke-Formatter + ## SYNOPSIS Formats a script text based on the input settings or default settings. ## SYNTAX ``` -Invoke-Formatter [-ScriptDefinition] [-Settings ] [-Range ] +Invoke-Formatter [-ScriptDefinition] [[-Settings] ] [[-Range] ] + [] ``` ## DESCRIPTION -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. +The `Invoke-Formatter` cmdlet takes a string input and formats it according to defined settings. If +no **Settings** parameter is provided, the cmdlet assumes the default code formatting settings as +defined in `Settings/CodeFormatting.psd1`. ## EXAMPLES -### -------------------------- EXAMPLE 1 -------------------------- -``` +### EXAMPLE 1 - Format the input script text using the default settings + +```powershell $scriptDefinition = @' function foo { "hello" @@ -30,10 +38,15 @@ function foo { Invoke-Formatter -ScriptDefinition $scriptDefinition ``` -This command formats the input script text using the default settings. - -### -------------------------- EXAMPLE 2 -------------------------- +```Output +function foo { + "hello" +} ``` + +### EXAMPLE 2 - Format the input script using the settings defined in a hashtable + +```powershell $scriptDefinition = @' function foo { "hello" @@ -56,21 +69,48 @@ $settings = @{ Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings ``` -This command formats the input script text using the settings defined in the $settings hashtable. - -### -------------------------- EXAMPLE 3 -------------------------- +```Output +function foo +{ + "hello" +} ``` + +### EXAMPLE 3 - Format the input script text using the settings defined a `.psd1` file + +```powershell Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings /path/to/settings.psd1 ``` -This command formats the input script text using the settings defined in the settings.psd1 file. - ## PARAMETERS +### -Range + +The range within which formatting should take place. The value of this parameter must be an array of +four integers. These numbers must be greater than 0. The four integers represent the following four +values in this order: + +- starting line number +- starting column number +- ending line number +- ending column number + +```yaml +Type: Int32[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ScriptDefinition -The script text to be formated. -*NOTE*: Unlike ScriptBlock parameter, the ScriptDefinition parameter require a string value. +The text of the script to be formatted represented as a string. This is not a **ScriptBlock** +object. ```yaml Type: String @@ -79,17 +119,19 @@ Aliases: Required: True Position: 1 -Default value: +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -Settings -A settings hashtable or a path to a PowerShell data file (.psd1) file that contains the settings. + +A settings hashtable or a path to a PowerShell data file (`.psd1`) that contains the settings. ```yaml Type: Object Parameter Sets: (All) +Aliases: Required: False Position: 2 @@ -98,21 +140,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Range -The range within which formatting should take place. The parameter is an array of integers of length 4 such that the first, second, third and last elements correspond to the start line number, start column number, end line number and end column number. These numbers must be greater than 0. +### CommonParameters -```yaml -Type: Int32[] -Parameter Sets: (All) +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). -Required: False -Position: 3 -Default value: -Accept pipeline input: False -Accept wildcard characters: False -``` +## INPUTS ## OUTPUTS ### System.String + The formatted string result. + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets/Invoke-ScriptAnalyzer.md b/docs/Cmdlets/Invoke-ScriptAnalyzer.md index 5282efbc8..54fe2d07c 100644 --- a/docs/Cmdlets/Invoke-ScriptAnalyzer.md +++ b/docs/Cmdlets/Invoke-ScriptAnalyzer.md @@ -1,6 +1,8 @@ ---- +--- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml Module Name: PSScriptAnalyzer +ms.date: 10/07/2021 +online version: https://docs.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 --- @@ -12,110 +14,133 @@ Evaluates a script or module based on selected best practice rules ## SYNTAX ### Path_SuppressedOnly (Default) + ``` -Invoke-ScriptAnalyzer [-Path] [-CustomRulePath ] [-RecurseCustomRulePath] - [-IncludeDefaultRules] [-ExcludeRule ] [-IncludeRule ] [-Severity ] [-Recurse] - [-SuppressedOnly] [-Fix] [-EnableExit] [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] - [-Confirm] [] +Invoke-ScriptAnalyzer [-Path] [-CustomRulePath ] [-RecurseCustomRulePath] + [-IncludeDefaultRules] [-ExcludeRule ] [-IncludeRule ] [-Severity ] + [-Recurse] [-SuppressedOnly] [-Fix] [-EnableExit] [-Settings ] [-SaveDscDependency] + [-ReportSummary] [-WhatIf] [-Confirm] [] ``` ### Path_IncludeSuppressed + ``` -Invoke-ScriptAnalyzer [-Path] [-CustomRulePath ] [-RecurseCustomRulePath] - [-IncludeDefaultRules] [-ExcludeRule ] [-IncludeRule ] [-Severity ] [-Recurse] - [-IncludeSuppressed] [-Fix] [-EnableExit] [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] - [-Confirm] [] +Invoke-ScriptAnalyzer [-Path] -IncludeSuppressed [-CustomRulePath ] + [-RecurseCustomRulePath] [-IncludeDefaultRules] [-ExcludeRule ] + [-IncludeRule ] [-Severity ] [-Recurse] [-Fix] [-EnableExit] + [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] [-Confirm] + [] ``` ### ScriptDefinition_IncludeSuppressed + ``` -Invoke-ScriptAnalyzer [-ScriptDefinition] [-CustomRulePath ] [-RecurseCustomRulePath] - [-IncludeDefaultRules] [-ExcludeRule ] [-IncludeRule ] [-Severity ] - [-IncludeSuppressed] [-EnableExit] [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] - [-Confirm] [] +Invoke-ScriptAnalyzer [-ScriptDefinition] -IncludeSuppressed [-CustomRulePath ] + [-RecurseCustomRulePath] [-IncludeDefaultRules] [-ExcludeRule ] + [-IncludeRule ] [-Severity ] [-Recurse] [-EnableExit] [-Settings ] + [-SaveDscDependency] [-ReportSummary] [-WhatIf] [-Confirm] [] ``` ### ScriptDefinition_SuppressedOnly + ``` -Invoke-ScriptAnalyzer [-ScriptDefinition] [-CustomRulePath ] [-RecurseCustomRulePath] - [-IncludeDefaultRules] [-ExcludeRule ] [-IncludeRule ] [-Severity ] - [-SuppressedOnly] [-EnableExit] [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] - [-Confirm] [] +Invoke-ScriptAnalyzer [-ScriptDefinition] [-CustomRulePath ] + [-RecurseCustomRulePath] [-IncludeDefaultRules] [-ExcludeRule ] + [-IncludeRule ] [-Severity ] [-Recurse] [-SuppressedOnly] [-EnableExit] + [-Settings ] [-SaveDscDependency] [-ReportSummary] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION -Invoke-ScriptAnalyzer evaluates a script or module files (.ps1, .psm1 and .psd1 files) based on a collection of best practice rules and returns objects -that represent rule violations. It also includes special rules to analyze DSC resources. -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. -Invoke-ScriptAnalyzer comes with a set of built-in rules, but you can also use customized rules that you write in -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. +`Invoke-ScriptAnalyzer` evaluates scripts or module files (`.ps1`, `.psm1`, and `.psd1` files) based +on a collection of best practice rules and returns objects that represent rule violations. It also +includes special rules to analyze DSC resources. -To analyze your script or module, begin by using the Get-ScriptAnalyzerRule cmdlet to examine and select the rules you -want to include and/or exclude from the evaluation. +`Invoke-ScriptAnalyzer` comes with a set of built-in rules. By default, it uses all rules. You can +use the **IncludeRule** and **ExcludeRule** parameters to select the rules you want. You can use the +`Get-ScriptAnalyzerRule` cmdlet to examine and select the rules you want to include or exclude from +the evaluation. -You can also include a rule in the analysis, but suppress the output of that rule for selected functions or scripts. -This feature should be used only when absolutely necessary. -To get rules that were suppressed, run Invoke-ScriptAnalyzer with the -SuppressedOnly parameter. -For instructions on suppressing a rule, see the description of the SuppressedOnly parameter. +You can also use customized rules that you write in PowerShell scripts, or compile in assemblies +using C#. Custom rules can also be selected using the **IncludeRule** and **ExcludeRule** +parameters. -For usage in CI systems, the -EnableExit exits the shell with an exit code equal to the number of error records. +You can also include a rule in the analysis, but suppress the output of that rule for selected +functions or scripts. This feature should be used only when necessary. To get rules that were +suppressed, run `Invoke-ScriptAnalyzer` with the **SuppressedOnly** parameter. -PSScriptAnalyzer is an open-source project. -For more information about PSScriptAnalyzer, to contribute or file an issue, see GitHub.com\PowerShell\PSScriptAnalyzer. +For usage in CI systems, the **EnableExit** exits the shell with an exit code equal to the number of +error records. ## EXAMPLES -### EXAMPLE 1 -``` +### EXAMPLE 1 - Run all Script Analyzer rules on a script + +```powershell Invoke-ScriptAnalyzer -Path C:\Scripts\Get-LogData.ps1 ``` -This command runs all Script Analyzer rules on the Get-LogData.ps1 script. +### EXAMPLE 2 - Run all Script Analyzer rules on all files in the Modules directory -### EXAMPLE 2 -``` +This example runs all Script Analyzer rules on all `.ps1` and `.psm1` files in your user-based +`Modules` directory and its subdirectories. + +```powershell Invoke-ScriptAnalyzer -Path $home\Documents\WindowsPowerShell\Modules -Recurse ``` -This command runs all Script Analyzer rules on all .ps1 and .psm1 files in the Modules directory and its -subdirectories. +### EXAMPLE 3 - Run a single rule on a module -### EXAMPLE 3 -``` +This example runs only the **PSAvoidUsingPositionalParameters** rule on the files in the +`PSDiagnostics` module folder. You can use a command like this to find all instances of a particular +rule violation. + +```powershell Invoke-ScriptAnalyzer -Path C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDiagnostics -IncludeRule PSAvoidUsingPositionalParameters ``` -This command runs only the PSAvoidUsingPositionalParameters rule on the files in the PSDiagnostics module. -You might use a command like this to find all instances of a particular rule violation while working to eliminate it. +### EXAMPLE 4 - Run all rules except two on your modules -### EXAMPLE 4 -``` +This example runs all rules except for **PSAvoidUsingCmdletAliases** and +**PSAvoidUsingInternalURLs** on the `.ps1` and `.psm1` files in the `MyModules` directory and in its +subdirectories. + +```powershell Invoke-ScriptAnalyzer -Path C:\ps-test\MyModule -Recurse -ExcludeRule PSAvoidUsingCmdletAliases, PSAvoidUsingInternalURLs ``` -This command runs Script Analyzer on the .ps1 and .psm1 files in the MyModules directory, including the scripts in its subdirectories, with all rules except for PSAvoidUsingCmdletAliases and PSAvoidUsingInternalURLs. +### EXAMPLE 5 - Run Script Analyzer with custom rules -### EXAMPLE 5 -``` -Invoke-ScriptAnalyzer -Path D:\test_scripts\Test-Script.ps1 -CustomRulePath C:\CommunityAnalyzerRules +This example runs Script Analyzer on `Test-Script.ps1` with the standard rules and rules in the +`C:\CommunityAnalyzerRules` path. + +```powershell +Invoke-ScriptAnalyzer -Path D:\test_scripts\Test-Script.ps1 -CustomRulePath C:\CommunityAnalyzerRules -IncludeDefaultRules ``` -This command runs Script Analyzer on Test-Script.ps1 with the standard rules and rules in the C:\CommunityAnalyzerRules path. +### EXAMPLE 6 - Run only the rules that are Error severity and have the PSDSC source name -### EXAMPLE 6 -``` +```powershell $DSCError = Get-ScriptAnalyzerRule -Severity Error | Where SourceName -eq PSDSC +$Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule" +Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse +``` -PS C:\>$Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule" +### EXAMPLE 7 - Suppressing rule violations -PS C:\> Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse -``` +This example shows how to suppress the reporting of rule violations in a function and how to +discover rule violations that are suppressed. -This example runs only the rules that are Error severity and have the PSDSC source name. +The example uses the `SuppressMessageAttribute` attribute to suppress the **PSUseSingularNouns** and +**PSAvoidUsingCmdletAliases** rules for the `Get-Widgets` function in the `Get-Widgets.ps1` script. +You can use this attribute to suppress a rule for a module, script, class, function, parameter, or +line. -### EXAMPLE 7 -``` +The first command runs Script Analyzer on the script file containing the function. The output +reports a rule violation. Even though more rules are violated, neither suppressed rule is reported. + +```powershell function Get-Widgets { [CmdletBinding()] @@ -127,15 +152,21 @@ function Get-Widgets ... } -PS C:\> Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 +Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 +``` +```Output RuleName Severity FileName Line Message -------- -------- -------- ---- ------- PSProvideCommentHelp Information ManageProf 14 The cmdlet 'Get-Widget' does not have a help comment. iles.psm1 +``` -PS C:\> Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 -SuppressedOnly +```powershell +Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 -SuppressedOnly +``` +```Output Rule Name Severity File Name Line Justification --------- -------- --------- ---- ------------- PSAvoidUsingCmdletAliases Warning ManageProf 21 Resolution in progress. @@ -144,24 +175,16 @@ PSUseSingularNouns Warning ManageProf 14 iles.psm1 ``` -This example shows how to suppress the reporting of rule violations in a function and how to discover rule violations -that are suppressed. - -The example uses the SuppressMessageAttribute attribute to suppress the PSUseSingularNouns and -PSAvoidUsingCmdletAliases rules for the Get-Widgets function in the Get-Widgets.ps1 script. -You can use this attribute -to suppress a rule for a module, script, class, function, parameter, or line. +The second command uses the **SuppressedOnly** parameter to report violations of the rules that are +suppressed script file. -The first command runs Script Analyzer on the script that contains the Get-Widgets function. -The output reports a rule -violation, but neither of the suppressed rules is listed, even though they are violated. +### EXAMPLE 8 - Analyze script files using a profile definition -The second command uses the SuppressedOnly parameter to discover the rules that are supressed in the Get-Widgets.ps1 -file. -The output reports the suppressed rules. +In this example, we create a Script Analyzer profile and save it in the `ScriptAnalyzerProfile.txt` +file in the current directory. We run `Invoke-ScriptAnalyzer` on the **BitLocker** module files. The +value of the **Profile** parameter is the path to the Script Analyzer profile. -### EXAMPLE 8 -``` +```powershell # In .\ScriptAnalyzerProfile.txt @{ Severity = @('Error', 'Warning') @@ -169,23 +192,22 @@ The output reports the suppressed rules. ExcludeRules = '*WriteHost' } -PS C:\> Invoke-ScriptAnalyzer -Path $pshome\Modules\BitLocker -Profile .\ScriptAnalyzerProfile.txt +Invoke-ScriptAnalyzer -Path $pshome\Modules\BitLocker -Profile .\ScriptAnalyzerProfile.txt ``` -In this example, we create a Script Analyzer profile and save it in the ScriptAnalyzerProfile.txt file in the local -directory. +If you include a conflicting parameter in the `Invoke-ScriptAnalyzer` command, such as +`-Severity Error`, the cmdlet uses the profile value and ignores the parameter. -Next, we run Invoke-ScriptAnalyzer on the BitLocker module files. -The value of the Profile parameter is the path to the -Script Analyzer profile. +### EXAMPLE 9 - Analyze a script stored as a string -If you include a conflicting parameter in the Invoke-ScriptAnalyzer command, such as '-Severity Error', -Invoke-ScriptAnalyzer uses the profile value and ignores the parameter. +This example uses the **ScriptDefinition** parameter to analyze a function at the command line. The +function string is enclosed in quotation marks. -### EXAMPLE 9 -``` +```powershell Invoke-ScriptAnalyzer -ScriptDefinition "function Get-Widgets {Write-Host 'Hello'}" +``` +```Output RuleName Severity FileName Line Message -------- -------- -------- ---- ------- PSAvoidUsingWriteHost Warning 1 Script @@ -197,45 +219,20 @@ PSUseSingularNouns Warning 1 The cmd noun sh ``` -This command uses the ScriptDefinition parameter to analyze a function at the command line. -The function string is enclosed in quotation marks. - -When you use the ScriptDefinition parameter, the FileName property of the DiagnosticRecord object is $null. +When you use the **ScriptDefinition** parameter, the **FileName** property of the +**DiagnosticRecord** object is `$null`. ## PARAMETERS -### -Path -Specifies the path to the scripts or module to be analyzed. -Wildcard characters are supported. - -Enter the path to a script (.ps1) or module file (.psm1) or to a directory that contains scripts or modules. -If the directory contains other types of files, they are ignored. - -To analyze files that are not in the root directory of the specified path, use a wildcard character -(C:\Modules\MyModule\*) or the Recurse parameter. - -```yaml -Type: String -Parameter Sets: Path_SuppressedOnly, Path_IncludeSuppressed -Aliases: PSPath - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - ### -CustomRulePath -Uses only the custom rules defined in the specified paths to the analysis. To still use the built-in rules, add the -IncludeDefaultRules switch. Enter the path to a file that defines rules or a directory that contains files that define rules. -Wildcard characters are supported. -To add rules defined in subdirectories of the path, use the RecurseCustomRulePath parameter. - -By default, Invoke-ScriptAnalyzer uses only rules defined in the Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll file in the PSScriptAnalyzer module. +Wildcard characters are supported. When **CustomRulePath** is specified, only the custom rules found +in the specified paths are used for the analysis. If `Invoke-ScriptAnalyzer` cannot find rules in +the , it runs the standard rules without notice. -If Invoke-ScriptAnalyzer cannot find rules in the CustomRulePath, it runs the standard rules without notice. +To add rules defined in subdirectories of the path, use the **RecurseCustomRulePath** parameter. To +include the built-in rules, add the **IncludeDefaultRules** parameter. ```yaml Type: String[] @@ -246,13 +243,13 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` -### -RecurseCustomRulePath -Adds rules defined in subdirectories of the CustomRulePath location. -By default, Invoke-ScriptAnalyzer uses only the custom rules defined in the specified file or directory. -To still use the built-in rules, additionally use the -IncludeDefaultRules switch. +### -EnableExit + +On completion of the analysis, this parameter exits the PowerShell sessions and returns an exit code +equal to the number of error records. This can be useful in continuous integration (CI) pipeline. ```yaml Type: SwitchParameter @@ -261,24 +258,25 @@ Aliases: Required: False Position: Named -Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` ### -ExcludeRule -Omits the specified rules from the Script Analyzer test. -Wildcard characters are supported. -Enter a comma-separated list of rule names, a variable that contains rule names, or a command that gets rule names. -You can also specify a list of excluded rules in a Script Analyzer profile file. +Omits the specified rules from the Script Analyzer test. Wildcard characters are supported. + +Enter a comma-separated list of rule names, a variable that contains rule names, or a command that +gets rule names. You can also specify a list of excluded rules in a Script Analyzer profile file. You can exclude standard rules and rules in a custom rule path. -When you exclude a rule, the rule does not run on any of the files in the path. -To exclude a rule on a particular line, parameter, function, script, or class, adjust the Path parameter or suppress the rule. -For information about suppressing a rule, see the examples. +When you exclude a rule, the rule does not run on any of the files in the path. To exclude a rule on +a particular line, parameter, function, script, or class, adjust the Path parameter or suppress the +rule. For information about suppressing a rule, see the examples. -If a rule is specified in both the ExcludeRule and IncludeRule collections, the rule is excluded. +If a rule is specified in both the **ExcludeRule** and **IncludeRule** collections, the rule is +excluded. ```yaml Type: String[] @@ -289,15 +287,20 @@ Required: False Position: Named Default value: All rules are included. Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` -### -IncludeDefaultRules -Invoke default rules along with Custom rules +### -Fix + +Fixes certain warnings that contain a fix in their **DiagnosticRecord**. + +When you used **Fix**, `Invoke-ScriptAnalyzer` applies the fixes before running the analysis. Make +sure that you have a backup of your files when using this parameter. It tries to preserve the file +encoding but there are still some cases where the encoding can change. ```yaml Type: SwitchParameter -Parameter Sets: (All) +Parameter Sets: Path_SuppressedOnly, Path_IncludeSuppressed Aliases: Required: False @@ -307,46 +310,39 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -IncludeRule -Runs only the specified rules in the Script Analyzer test. -By default, PSScriptAnalyzer runs all rules. - -Enter a comma-separated list of rule names, a variable that contains rule names, or a command that gets rule names. -Wildcard characters are supported. -You can also specify rule names in a Script Analyzer profile file. - -When you use the CustomizedRulePath parameter, you can use this parameter to include standard rules and rules in the -custom rule paths. - -If a rule is specified in both the ExcludeRule and IncludeRule collections, the rule is excluded. +### -IncludeDefaultRules -Also, Severity takes precedence over IncludeRule. -For example, if Severity is Error, you cannot use IncludeRule to include a Warning rule. +Invoke default rules along with Custom rules. ```yaml -Type: String[] +Type: SwitchParameter Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: All rules are included. +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -### -Severity -After running Script Analyzer with all rules, this parameter selects rule violations with the specified severity. +### -IncludeRule -Valid values are: Error, Warning, and Information. -You can specify one ore more severity values. +Runs only the specified rules in the Script Analyzer test. By default, PSScriptAnalyzer runs all +rules. + +Enter a comma-separated list of rule names, a variable that contains rule names, or a command that +gets rule names. Wildcard characters are supported. You can also specify rule names in a Script +Analyzer profile file. -Because this parameter filters the rules only after running with all rules, it is not an efficient filter. -To filter rules efficiently, use Get-ScriptAnalyzer rule to get the rules you want to run or exclude and -then use the ExcludeRule or IncludeRule parameters. +When you use the **CustomizedRulePath** parameter, you can use this parameter to include standard +rules and rules in the custom rule paths. -Also, Severity takes precedence over IncludeRule. -For example, if Severity is Error, you cannot use IncludeRule to include a Warning rule. +If a rule is specified in both the **ExcludeRule** and **IncludeRule** collections, the rule is +excluded. + +The **Severity** parameter takes precedence over **IncludeRule**. For example, if **Severity** is +`Error`, you cannot use **IncludeRule** to include a `Warning` rule. ```yaml Type: String[] @@ -355,41 +351,59 @@ Aliases: Required: False Position: Named -Default value: All rule violations +Default value: All rules are included. Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` -### -Recurse -Runs Script Analyzer on the files in the Path directory and all subdirectories recursively. +### -IncludeSuppressed -Recurse applies only to the Path parameter value. -To search the CustomRulePath recursively, use the RecurseCustomRulePath parameter. +Include suppressed diagnostics in output. ```yaml Type: SwitchParameter -Parameter Sets: Path_SuppressedOnly, Path_IncludeSuppressed +Parameter Sets: Path_IncludeSuppressed, ScriptDefinition_IncludeSuppressed Aliases: -Required: False +Required: True Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -### -SuppressedOnly -Returns rules that are suppressed, instead of analyzing the files in the path. +### -Path + +Specifies the path to the scripts or module to be analyzed. Wildcard characters are supported. + +Enter the path to a script (`.ps1`) or module file (`.psm1`) or to a directory that contains scripts +or modules. If the directory contains other types of files, they are ignored. + +To analyze files that are not in the root directory of the specified path, use a wildcard character +(`C:\Modules\MyModule\*`) or the **Recurse** parameter. -When you used SuppressedOnly, Invoke-ScriptAnalyzer returns a SuppressedRecord object -(Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.SuppressedRecord). +```yaml +Type: String +Parameter Sets: Path_SuppressedOnly, Path_IncludeSuppressed +Aliases: PSPath + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: True +``` + +### -Recurse -To suppress a rule, use the SuppressMessageAttribute. -For help, see the examples. +Runs Script Analyzer on the files in the **Path** directory and all subdirectories recursively. + +Recurse applies only to the Path parameter value. To search the **CustomRulePath** recursively, use +the **RecurseCustomRulePath** parameter. ```yaml Type: SwitchParameter -Parameter Sets: Path_SuppressedOnly, ScriptDefinition_SuppressedOnly +Parameter Sets: (All) Aliases: Required: False @@ -399,16 +413,15 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Fix -Fixes certain warnings which contain a fix in their DiagnosticRecord. +### -RecurseCustomRulePath -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. +Adds rules defined in subdirectories of the **CustomRulePath** location. By default, +`Invoke-ScriptAnalyzer` uses only the custom rules defined in the specified file or directory. To +include the built-in rules, use the **IncludeDefaultRules** parameter. ```yaml Type: SwitchParameter -Parameter Sets: Path_SuppressedOnly, Path_IncludeSuppressed +Parameter Sets: (All) Aliases: Required: False @@ -418,8 +431,9 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -EnableExit -Exits PowerShell and returns an exit code equal to the number of error records. This can be useful in CI systems. +### -ReportSummary + +Write a summary of the violations found to the host. ```yaml Type: SwitchParameter @@ -433,8 +447,18 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ReportSummary -Writes a report summary of the found warnings to the host. +### -SaveDscDependency + +Resolve DSC resource dependencies. + +When `Invoke-ScriptAnalyzer` is run with this parameter, it looks for instances of +`Import-DSCResource -ModuleName `. If `` is cannot be found by searching the +`$env:PSModulePath`, `Invoke-ScriptAnalyzer` returns parse error. This error is caused by the +PowerShell parser not being able to find the symbol for ``. + +If `Invoke-ScriptAnalyzer` finds the module in the PowerShell Gallery, it downloads the missing +module to a temp path. The temp path is then added to `$env:PSModulePath` for duration of the scan. +The temp location can be found in `$LOCALAPPDATA/PSScriptAnalyzer/TempModuleDir`. ```yaml Type: SwitchParameter @@ -448,46 +472,48 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Settings -File path that contains user profile or hash table for ScriptAnalyzer - -Runs Invoke-ScriptAnalyzer with the parameters and values specified in a Script Analyzer profile file or hash table +### -ScriptDefinition -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. +Runs the analysis on commands, functions, or expressions in a string. You can use this feature to +analyze statements, expressions, and functions, independent of their script context. -A Script Analyzer profile file is a text file that contains a hash table with one or more of the following keys: +```yaml +Type: String +Parameter Sets: ScriptDefinition_IncludeSuppressed, ScriptDefinition_SuppressedOnly +Aliases: --- CustomRulePath --- ExcludeRules --- IncludeDefaultRules --- IncludeRules --- RecurseCustomRulePath --- Rules --- Severity +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` -The keys and values in the profile are interpreted as if they were standard parameters and parameter values of Invoke-ScriptAnalyzer. +### -Settings -To specify a single value, enclose the value in quotation marks. -For example: +A path to a file containing a user-defined profile or a hashtable object containing settings for +ScriptAnalyzer. - @{ Severity = 'Error'} +Runs `Invoke-ScriptAnalyzer` with the parameters and values specified in the file or hashtable. -To specify multiple values, enclose the values in an array. -For example: +If the path or the content of the file or hashtable is invalid, it is ignored. The parameters and +values in the profile take precedence over the same parameter and values specified at the command +line. - @{ Severity = 'Error', 'Warning'} +A Script Analyzer profile file is a text file that contains a hashtable with one or more of the +following keys: -A more sophisticated example is: +- CustomRulePath +- ExcludeRules +- IncludeDefaultRules +- IncludeRules +- RecurseCustomRulePath +- Rules +- Severity - @{ - CustomRulePath='path\to\CustomRuleModule.psm1' - IncludeDefaultRules=$true - ExcludeRules = @( - 'PSAvoidUsingWriteHost', - 'MyCustomRuleName' - ) - } +The keys and values in the profile are interpreted as if they were standard parameters and values of +`Invoke-ScriptAnalyzer`, similar to splatting. For more information, see +[about_Splatting](/powershell/module/microsoft.powershell.com/about/about_splatting). ```yaml Type: Object @@ -501,72 +527,76 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ScriptDefinition -Runs Invoke-ScriptAnalyzer on commands, functions, or expressions in a string. -You can use this feature to analyze statements, expressions, and functions, independent of their script context. +### -Severity -Unlike ScriptBlock parameters, the ScriptDefinition parameter requires a string value. +After running Script Analyzer with all rules, this parameter selects rule violations with the +specified severity. -```yaml -Type: String -Parameter Sets: ScriptDefinition_IncludeSuppressed, ScriptDefinition_SuppressedOnly -Aliases: +Valid values are: -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` +- Error +- Warning +- Information. -### -SaveDscDependency -Resolve DSC resource dependency +You can specify one ore more severity values. -Whenever Invoke-ScriptAnalyzer is run on a script having the dynamic keyword "Import-DSCResource -ModuleName ", if 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 . 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. +The parameter filters the rules violations only after running all rules. To filter rules +efficiently, use `Get-ScriptAnalyzerRule` to select the rules you want to run. + +The **Severity** parameter takes precedence over **IncludeRule**. For example, if **Severity** is +`Error`, you cannot use **IncludeRule** to include a `Warning` rule. ```yaml -Type: SwitchParameter +Type: String[] Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: False +Default value: All rule violations Accept pipeline input: False Accept wildcard characters: False ``` -### -Confirm -Prompts you for confirmation before running the cmdlet. +### -SuppressedOnly + +Returns violations only for rules that are suppressed. + +Returns a **SuppressedRecord** object +(**Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.SuppressedRecord**). + +To suppress a rule, use the **SuppressMessageAttribute**. For help, see the examples. ```yaml Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf +Parameter Sets: Path_SuppressedOnly, ScriptDefinition_SuppressedOnly +Aliases: Required: False Position: Named -Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -### -IncludeSuppressed -Include suppressed diagnostics in output. +### -Confirm + +Prompts you for confirmation before running the cmdlet. ```yaml Type: SwitchParameter -Parameter Sets: Path_IncludeSuppressed, ScriptDefinition_IncludeSuppressed -Aliases: +Parameter Sets: (All) +Aliases: cf -Required: True +Required: False Position: Named -Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml @@ -576,31 +606,39 @@ Aliases: wi Required: False Position: Named -Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### None + You cannot pipe input to this cmdlet. ## OUTPUTS ### Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord -By default, Invoke-ScriptAnalyzer returns one DiagnosticRecord object to report a rule violation. + +By default, `Invoke-ScriptAnalyzer` returns one **DiagnosticRecord** object for each rule violation. ### Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.SuppressedRecord -If you use the SuppressedOnly parameter, Invoke-ScriptAnalyzer instead returns a SuppressedRecord object. + +If you use the **SuppressedOnly** parameter, `Invoke-ScriptAnalyzer` instead returns a +**SuppressedRecord** objects. ## NOTES ## RELATED LINKS -[Get-ScriptAnalyzerRule]() +[Get-ScriptAnalyzerRule](Get-ScriptAnalyzerRule.md) [PSScriptAnalyzer on GitHub](https://github.com/PowerShell/PSScriptAnalyzer) diff --git a/docs/Cmdlets/PSScriptAnalyzer.md b/docs/Cmdlets/PSScriptAnalyzer.md new file mode 100644 index 000000000..10ebbe44f --- /dev/null +++ b/docs/Cmdlets/PSScriptAnalyzer.md @@ -0,0 +1,30 @@ +--- +Module Name: PSScriptAnalyzer +Module Guid: d6245802-193d-4068-a631-8863a4342a18 +ms.date: 10/07/2021 +Download Help Link: https://aka.ms/ps-modules-help +Help Version: 1.20.0 +Locale: en-US +--- + +# PSScriptAnalyzer Module + +## Description + +PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzer +checks the quality of PowerShell code by running a set of rules. + +> [!NOTE] +> Support for the module is limited. Please file issues in the source repository using the **This +> product** button in the Feedback section at the bottom of the page. + +## PSScriptAnalyzer Cmdlets + +### [Get-ScriptAnalyzerRule](Get-ScriptAnalyzerRule.md) +Gets the script analyzer rules on the local computer. + +### [Invoke-Formatter](Invoke-Formatter.md) +Formats a script text based on the input settings or default settings. + +### [Invoke-ScriptAnalyzer](Invoke-ScriptAnalyzer.md) +Evaluates a script or module based on selected best practice rules