11---
22description : This article describes various features of PSScriptAnalyzer and how to use them.
3- ms.date : 04/26/2024
3+ ms.date : 01/28/2026
44title : Using PSScriptAnalyzer
55---
66# Using PSScriptAnalyzer
@@ -104,7 +104,7 @@ function InternalFunction
104104}
105105```
106106
107- You can further restrict suppression based on a function, parameter, class, variable or object's
107+ You can further restrict suppression based on a function, parameter, class, variable, or object's
108108name by setting the ** Target** property of ** SuppressMessageAttribute** to a regular expression or
109109a wildcard pattern.
110110
@@ -155,8 +155,8 @@ Param()
155155
156156You can create settings that describe the ScriptAnalyzer rules to include or exclude based on
157157** Severity** . Use the ** Settings** parameter of ` Invoke-ScriptAnalyzer ` to specify configuration.
158- This enables you to create a custom configuration for a specific environment. We support the
159- following modes for specifying the settings file:
158+ The ** Settings ** parameter allows you to create a custom configuration for a specific environment.
159+ ScriptAnalyzer support the following modes for specifying the settings file:
160160
161161### Built-in Presets
162162
@@ -214,8 +214,8 @@ If you place a settings file named `PSScriptAnalyzerSettings.psd1` in your proje
214214Invoke-ScriptAnalyzer -Path "C:\path\to\project" -Recurse
215215```
216216
217- Note that providing settings explicitly takes higher precedence over this implicit mode. Sample
218- settings files are provided in the ` Settings ` folder of the ** PSScriptAnalyzer** module.
217+ Providing settings explicitly takes higher precedence over this implicit mode. You can find sample
218+ settings files in the ` Settings ` folder of the ** PSScriptAnalyzer** module.
219219
220220## Check PowerShell version compatibility
221221
@@ -227,8 +227,8 @@ issues:
227227 PowerShell environments
228228- [ PSUseCompatibleCommands] [ 04 ] checks whether commands used in a script are available in other
229229 PowerShell environments
230- - [ PSUseCompatibleSyntax] [ 05 ] checks whether a syntax used in a script will work in other PowerShell
231- versions
230+ - [ PSUseCompatibleSyntax] [ 05 ] checks whether a syntax used in a script is compatible in other
231+ versions of PowerShell
232232- [ PSUseCompatibleTypes] [ 06 ] checks whether .NET types and static methods or properties are
233233 available in other PowerShell environments
234234
@@ -242,8 +242,8 @@ these paths point either to a module's folder, which implicitly uses the module
242242module's script file (` .psm1 ` ). The module must export the custom rule functions using
243243` Export-ModuleMember ` for them to be available to ** PSScriptAnalyzer** .
244244
245- In this example the property ** CustomRulePath** points to two different modules. Both modules export
246- the rule functions with the verb ** Measure** so ` Measure-* ` is used for the property
245+ In this example, the ** CustomRulePath** property points to two different modules. Both modules
246+ export the rule functions with the verb ** Measure** so ` Measure-* ` is used for the property
247247** IncludeRules** .
248248
249249``` powershell
@@ -283,10 +283,10 @@ otherwise the default rules are used.
283283}
284284```
285285
286- ### Using custom rules in Visual Studio Code
286+ ### Using custom rules in Visual Studio Code (VS Code)
287287
288- It's also possible to use the custom rules that are provided in the settings file in Visual Studio
289- Code. This is done by adding a Visual Studio Code workspace settings file (` .vscode/settings.json ` ).
288+ You can also use the custom rules that are provided in the settings file in VS Code. Add a VS Code
289+ workspace settings file (` .vscode/settings.json ` ) with the following contents .
290290
291291``` json
292292{
@@ -322,16 +322,16 @@ public System.Collections.Generic.IEnumerable<IRule> GetRule(string[] moduleName
322322
323323## Violation Correction
324324
325- You can use the ** Fix** switch to to automatically replace violation-causing content with a
326- suggested alternative. Additionally, because ` Invoke-ScriptAnalyzer ` implements
327- ** SupportsShouldProcess ** , you can use ** WhatIf** or ** Confirm** to find out which corrections would
328- be applied. You should use source control when applying corrections as some changes, such as the one
329- for ** AvoidUsingPlainTextForPassword** , might require additional script modifications that can't be
330- made automatically. Because initial encoding can't always be preserved when you automatically apply
331- suggestions, you should check your file's encoding if your scripts depend on a particular encoding.
325+ You can use the ** Fix** switch to automatically replace violation-causing content with a suggested
326+ alternative. Additionally, because ` Invoke-ScriptAnalyzer ` implements ** SupportsShouldProcess ** , you
327+ can use ** WhatIf** or ** Confirm** to find out which corrections would be applied. You should use
328+ source control when applying corrections as some changes, such as the one for
329+ ** AvoidUsingPlainTextForPassword** , might require other script modifications that can't be made
330+ automatically. Initial encoding can't always be preserved when you automatically apply suggestions.
331+ You should check file encoding if your scripts depend on a particular encoding.
332332
333333The ** SuggestedCorrections** property of the error record enables quick-fix scenarios in editors
334- like VSCode . We provide valid ** SuggestedCorrection** for the following rules:
334+ like VS Code . We provide valid ** SuggestedCorrection** for the following rules:
335335
336336- ** AvoidAlias**
337337- ** AvoidUsingPlainTextForPassword**
0 commit comments