Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid long lines
ms.date: 06/28/2023
ms.date: 04/29/2025
ms.topic: reference
title: AvoidLongLines
---
Expand All @@ -10,10 +10,11 @@ title: AvoidLongLines

## Description

Lines should be no longer than a configured number of characters (default: 120), including leading
whitespace (indentation).
The length of lines, including leading spaces (indentation), should less than the configured number
of characters. The default length is 120 characters.

**Note**: This rule is not enabled by default. The user needs to enable it through settings.
> [!NOTE]
> This rule isn't enabled by default. The user needs to enable it through settings.

## Configuration

Expand All @@ -26,12 +27,12 @@ Rules = @{
}
```

### Parameters
## Parameters

#### Enable: bool (Default value is `$false`)
### `Enable`: bool (Default value is `$false`)

Enable or disable the rule during ScriptAnalyzer invocation.

#### MaximumLineLength: int (Default value is 120)
### `MaximumLineLength`: int (Default value is 120)

Optional parameter to override the default maximum line length.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Avoid Using SecureString With Plain Text
ms.date: 06/28/2023
ms.date: 01/28/2025
ms.topic: reference
title: AvoidUsingConvertToSecureStringWithPlainText
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use exact casing of cmdlet/function/parameter name.
ms.date: 06/28/2023
ms.date: 03/19/2025
ms.topic: reference
title: UseCorrectCasing
---
Expand All @@ -10,26 +10,66 @@ title: UseCorrectCasing

## Description

This is a style/formatting rule. PowerShell is case insensitive where applicable. The casing of
cmdlet names or parameters does not matter but this rule ensures that the casing matches for
consistency and also because most cmdlets/parameters start with an upper case and using that
improves readability to the human eye.
This is a style/formatting rule. PowerShell is case insensitive wherever possible, so the casing of
cmdlet names, parameters, keywords and operators does not matter. This rule nonetheless ensures
consistent casing for clarity and readability. Using lowercase keywords helps distinguish them from
commands. Using lowercase operators helps distinguish them from parameters.

## How

Use exact casing of the cmdlet and its parameters, e.g.
`Invoke-Command { 'foo' } -RunAsAdministrator`.
- Use exact casing for type names.
- Use exact casing of the cmdlet and its parameters.
- Use lowercase for language keywords and operators.

## Example
## Configuration

### Wrong
```powershell
Rules = @{
PS UseCorrectCasing = @{
Enable = $true
CheckCommands = $true
CheckKeyword = $true
CheckOperator = $true
}
}
```

### Parameters

#### Enable: bool (Default value is `$false`)

Enable or disable the rule during ScriptAnalyzer invocation.

#### CheckCommands: bool (Default value is `$true`)

If true, require the case of all operators to be lowercase.

#### CheckKeyword: bool (Default value is `$true`)

If true, require the case of all keywords to be lowercase.

#### CheckOperator: bool (Default value is `$true`)

If true, require the case of all commands to match their actual casing.

## Examples

### Wrong way

```powershell
ForEach ($file in Get-childitem -Recurse) {
$file.Extension -eq '.txt'
}

invoke-command { 'foo' } -runasadministrator
```

### Correct
### Correct way

```powershell
foreach ($file in Get-ChildItem -Recurse) {
$file.Extension -eq '.txt'
}

Invoke-Command { 'foo' } -RunAsAdministrator
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: This article lists the updates to the PSScriptAnalyzer module.
ms.date: 10/10/2024
ms.date: 04/29/2025
title: What's new in PSScriptAnalyzer
---
# What's new in PSScriptAnalyzer
Expand All @@ -9,6 +9,29 @@ PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. Th
the important changes in PSScriptAnalyzer. For a full list of changes, see the PSScriptAnalyzer
[CHANGELOG][01].

## PSScriptAnalyzer 1.24.0 - 2025-03-18

Breaking changes

- Minimum required PowerShell version raised from 3 to 5.1

New features and updates

- Add new options (enabled by default) to formatting rule `UseCorrectCasing` to also correct
operators, keywords and commands
- `PSAlignAssignmentStatement`: Ignore hashtables with a single key-value pair
- Use `RequiredResource` hashtable to specify PowerShell module versions
- `PSAvoidAssignmentToAutomaticVariable`: Ignore when a Parameter has an Attribute that contains a
Variable expression
- Trim unnecessary trailing spaces from string resources in Strings.resx
- Make Settings type detection more robust
- Add foreach Assignment to `AvoidAssignmentToAutomaticVariable`
- Do not print summary repeatedly for each logger
- Set exit code of `Invoke-ScriptAnalyzer -EnableExit` to total number of diagnostics
- `Invoke-ScriptAnalyzer`: Stream diagnostics instead of batching
- `Invoke-ScriptAnalyzer`: Print summary only once per invocation
- `Invoke-ScriptAnalyzer`: Include parse errors in reported error count

## PSScriptAnalyzer 1.23.0 - 2024-10-09

Small maintenance release to update the build pipeline and fix two issues:
Expand Down
2 changes: 1 addition & 1 deletion reference/docs-conceptual/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ items:
href: PlatyPS/overview.md
- name: Create help using PlatyPS
href: PlatyPS/create-help-using-platyps.md
- name: PSScriptAnalyzer v1.23
- name: PSScriptAnalyzer v1.24
items:
- name: Overview
href: PSScriptAnalyzer/overview.md
Expand Down
Loading