Skip to content

Commit 7df29ed

Browse files
authored
Update freshness (#373)
1 parent 08c450f commit 7df29ed

6 files changed

Lines changed: 59 additions & 54 deletions

File tree

reference/docfx.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"docs-conceptual/PSScriptAnalyzer/Rules/**": "language-reference"
4848
},
4949
"ms.update-cycle": {
50+
"docs-conceptual/AIShell/**": "1825-days",
5051
"docs-conceptual/Crescendo/**": "1825-days",
5152
"docs-conceptual/SecretManagement/**": "1825-days",
5253
"docs-conceptual/SecretStore/**": "1825-days",
@@ -76,6 +77,7 @@
7677
"ms.devlang": "powershell",
7778
"ms.service": "powershell",
7879
"ms.tgt_pltfr": "windows, macos, linux",
80+
"ms.update-cycle": "365-days",
7981
"products": [ "https://authoring-docs-microsoft.poolparty.biz/devrel/8bce367e-2e90-4b56-9ed5-5e4e9f3a2dc3" ],
8082
"social_image_url": "https://learn.microsoft.com/media/logos/logo-powershell-social.png",
8183
"titleSuffix": "PowerShell",

reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
description: This article provides a basic guide for creating your own customized rules.
3-
ms.date: 06/28/2023
3+
ms.date: 01/28/2026
44
title: Creating custom rules
55
---
66
# Creating custom rules
77

88
PSScriptAnalyzer uses the [Managed Extensibility Framework (MEF)][01] to import all rules defined in
99
the assembly. It can also consume rules written in PowerShell scripts.
1010

11-
When calling `Invoke-ScriptAnalyzer`, users can specify custom rules using the
12-
**CustomizedRulePath** parameter.
11+
Users can specify custom rules using the **CustomizedRulePath** parameter of the
12+
`Invoke-ScriptAnalyzer` cmdlet.
1313

1414
This article provides a basic guide for creating your own customized rules.
1515

1616
## Basic requirements
1717

1818
### Functions should have comment-based help
1919

20-
Include the `.DESCRIPTION` field. This becomes the description for the customized rule.
20+
Include the `.DESCRIPTION` field. This field becomes the description for the customized rule.
2121

2222
```powershell
2323
<#
@@ -114,7 +114,9 @@ $suggestedCorrections.add($correctionExtent) | Out-Null
114114
}
115115
```
116116

117-
### Make sure you export the function(s)
117+
### Make sure you export the function
118+
119+
You must export the functions you create so that PSScriptAnalyzer can find them.
118120

119121
```powershell
120122
Export-ModuleMember -Function (FunctionName)

reference/docs-conceptual/PSScriptAnalyzer/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: This article explains the purpose of the PSScriptAnalyzer module.
3-
ms.date: 10/10/2024
3+
ms.date: 01/28/2026
44
title: PSScriptAnalyzer module
55
---
66
# PSScriptAnalyzer module
@@ -20,8 +20,8 @@ PowerShell code such as:
2020
- And many more
2121

2222
You can choose the rules to include or exclude for your modules and scripts. PSScriptAnalyzer can
23-
also fix the formatting of your code. This helps you produce code that conforms to a standard style,
24-
is easier to read, and is more maintainable.
23+
also fix the formatting of your code. Formatting helps you produce code that conforms to a standard
24+
style that is more maintainable and easier to read.
2525

2626
## Installing PSScriptAnalyzer
2727

reference/docs-conceptual/PSScriptAnalyzer/rules-recommendations.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
description: This article lists best-practice recommendations and the rules associated with them.
3-
ms.date: 12/03/2024
3+
ms.date: 01/28/2026
44
title: PSScriptAnalyzer rules and recommendations
55
---
66
# PSScriptAnalyzer rules and recommendations
77

88
The following guidelines come from a combined effort from both the PowerShell team and the
9-
community. The guidelines are organized by type. Within each type there is a list of rules. The
9+
community. The guidelines are organized by type. Within each type, there's a list of rules. The
1010
rules are grouped by the **Severity** defined in the implementation of the **PSScriptAnalyzer**
11-
rule. The severity level labeled as 'TBD' means "To be determined". These are recommendations that
12-
don't currently have rules defined.
11+
rule. The severity level labeled `TBD` means "To be determined." Items labeled as TBD are
12+
recommendations that don't currently have rules defined.
1313

1414
## Cmdlet Design Rules
1515

@@ -42,8 +42,8 @@ No rules defined.
4242

4343
- Support **Force** parameter for interactive sessions. If your cmdlet is used interactively, always
4444
provide a **Force** parameter to override the interactive actions, such as prompts or reading
45-
lines of input. This is important because it allows your cmdlet to be used in non-interactive
46-
scripts and hosts. The following methods can be implemented by an interactive host.
45+
lines of input. The **Force** parameter is important because it allows your cmdlet to be used in
46+
non-interactive scripts and hosts.
4747
- Document output objects
4848
- Module must be loadable
4949
- No syntax errors
@@ -85,7 +85,7 @@ No rules defined.
8585
- Avoid using UNC file paths
8686
- Error Handling
8787
- Use `-ErrorAction Stop` when calling cmdlets
88-
- Use `$ErrorActionPreference = 'Stop'/'Continue'` when calling non-cmdlets
88+
- Use `$ErrorActionPreference` set to `Stop` or `Continue` when calling noncmdlets
8989
- Avoid using flags to handle errors
9090
- Avoid using `$?`
9191
- Avoid testing for a null variable as an error condition
@@ -142,7 +142,7 @@ No rules defined.
142142

143143
### Severity: TBD
144144

145-
- Avoid initializing APIKey and Credentials variables (information disclosure)
145+
- Avoid initializing API key and credential variables (information disclosure)
146146

147147
## DSC Related Rules
148148

@@ -168,13 +168,14 @@ No rules defined.
168168

169169
### Severity: TBD
170170

171-
- For Windows PowerShell v4, resource modules should have a `.psd1` file and `schema.mof` for every
171+
- For Windows PowerShell v4, resource modules should have a `.psd1` and `schema.mof` file for every
172172
resource
173-
- MOFs should have a description for each element - see [Issue #131][131]
174173
- Resource modules should have a `.psd1` file (always) and `schema.mof` (for non-class resource) see
175174
[Issue #116][116]
175+
- Resource module should have a DscResources folder that contains the resources - see
176+
[Issue #130][130]
177+
- MOFs should have a description for each element - see [Issue #131][131]
176178
- Use **ShouldProcess** for a **Set** DSC method
177-
- Resource module contains DscResources folder which contains the resources - see [Issue #130][130]
178179

179180
### References
180181

reference/docs-conceptual/PSScriptAnalyzer/using-scriptanalyzer.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: This article describes various features of PSScriptAnalyzer and how to use them.
3-
ms.date: 04/26/2024
3+
ms.date: 01/28/2026
44
title: 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
108108
name by setting the **Target** property of **SuppressMessageAttribute** to a regular expression or
109109
a wildcard pattern.
110110

@@ -155,8 +155,8 @@ Param()
155155

156156
You 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
214214
Invoke-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
242242
module'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

333333
The **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**

reference/docs-conceptual/PSScriptAnalyzer/whats-new-in-pssa.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: This article lists the updates to the PSScriptAnalyzer module.
3-
ms.date: 04/29/2025
3+
ms.date: 01/28/2026
44
title: What's new in PSScriptAnalyzer
55
---
66
# What's new in PSScriptAnalyzer
@@ -18,15 +18,15 @@ Breaking changes
1818
New features and updates
1919

2020
- Add new options (enabled by default) to formatting rule `UseCorrectCasing` to also correct
21-
operators, keywords and commands
21+
operators, keywords, and commands
2222
- `PSAlignAssignmentStatement`: Ignore hashtables with a single key-value pair
2323
- Use `RequiredResource` hashtable to specify PowerShell module versions
2424
- `PSAvoidAssignmentToAutomaticVariable`: Ignore when a Parameter has an Attribute that contains a
2525
Variable expression
2626
- Trim unnecessary trailing spaces from string resources in Strings.resx
2727
- Make Settings type detection more robust
2828
- Add foreach Assignment to `AvoidAssignmentToAutomaticVariable`
29-
- Do not print summary repeatedly for each logger
29+
- Don't print summary repeatedly for each logger
3030
- Set exit code of `Invoke-ScriptAnalyzer -EnableExit` to total number of diagnostics
3131
- `Invoke-ScriptAnalyzer`: Stream diagnostics instead of batching
3232
- `Invoke-ScriptAnalyzer`: Print summary only once per invocation
@@ -52,8 +52,8 @@ when using PowerShell 7 is now `7.2.11`.
5252
### Enhancements
5353

5454
- Enable suppression of `PSAvoidAssignmentToAutomaticVariable` for specific variable or parameter
55-
- Upgrade to use .NET 6 since PowerShell 7.0 is now out out of support
56-
- Convert `PSUseSingularNouns` to configurable rule and add `Windows` to allowlist
55+
- Upgrade to use .NET 6 since PowerShell 7.0 is now out of support
56+
- Convert `PSUseSingularNouns` to configurable rule and add `Windows` to the allow list
5757
- Allow suppression of `PSUseSingularNouns` for specific function
5858
- Add `ErrorView` to `SpecialVars.cs`
5959
- Adding `ToString()` methods to `[CorrectionExtent]` and `[DiagnosticRecord]` types
@@ -77,7 +77,7 @@ when using PowerShell 7 is now `7.2.11`.
7777
- Make messages of `UseCorrectCasing` more detailed
7878
- Exclude automatic variable `$FormatEnumerationLimit` from analysis by `PSAvoidGlobalVars` and
7979
`PSUseDeclaredVarsMoreThanAssignments`
80-
- `PSAvoidUsingPositionalParameters` - Do not warn on AZ CLI
80+
- `PSAvoidUsingPositionalParameters` - Don't warn on AzCLI
8181

8282
## PSScriptAnalyzer 1.20.0 - 2021-08-20
8383

@@ -90,29 +90,29 @@ when using PowerShell 7 is now `7.2.11`.
9090

9191
- Replace unhelpful warning about `process` aliasing `Get-Process` with warning about misused syntax
9292
- Fix `FunctionInfo` fallback AST attribute analysis for `UseShouldProcessCorrectly`
93-
- Do not increase indentation after a left parenthesis if the previous token is a newline and the
94-
next token is not a newline
93+
- Don't increase indentation after a left parenthesis if the previous token is a newline and the
94+
next token isn't a newline
9595
- `UseConsistentWhitespace` - **CheckOpenBrace** setting to not warn when being preceded by open
9696
parenthesis
9797
- Implement `-IncludeSuppressions` parameter
98-
- Combine multiple suppressions applied to the same diagnostic
98+
- Combine multiple suppressions that apply to the same diagnostic
9999

100100
## PSScriptAnalyzer 1.19.1 - 2020-07-28
101101

102102
### New rules
103103

104-
- Add `AvoidUsingDoubleQuotesForConstantString` (disabled by default) to warn about the use of
104+
- Add `AvoidUsingDoubleQuotesForConstantString` (disabled by default) - Warns about the use of
105105
double quotes for constant strings
106106

107107
### Fixes
108108

109-
- `UseCorrectCasing` - Do not use **CommandInfoCache** when **CommandInfoParameters** property
110-
throws due to runspace affinity problem of PowerShell engine
111-
- `ReviewUnusedParameter` - Do not trigger when `$MyInvocation.BoundParameters` or
109+
- `UseCorrectCasing` - Don't use **CommandInfoCache** when the **CommandInfoParameters** property
110+
throws. Fixes runspace affinity problem in the PowerShell engine
111+
- `ReviewUnusedParameter` - Don't trigger when `$MyInvocation.BoundParameters` or
112112
`$PSCmdlet.MyInvocation.BoundParameters` is used
113113
- `PipelineIndentationStyle.None` - Fix bug that caused incorrect formatting in hashtables
114114
- `UseUsingScopeModifierInNewRunspaces` - Fix `ArgumentException` when the same variable name is
115-
used in 2 different sessions.
115+
used in two different sessions.
116116
- `UseConsistentWhitespace`
117117
- Check previous token only if it starts on the same line
118118
- Fix **CheckParameter** bug when using interpolated string

0 commit comments

Comments
 (0)