1
1
---
2
2
description : Use exact casing of cmdlet/function/parameter name.
3
- ms.date : 06/28/2023
3
+ ms.date : 03/19/2025
4
4
ms.topic : reference
5
5
title : UseCorrectCasing
6
6
---
@@ -10,10 +10,16 @@ title: UseCorrectCasing
10
10
11
11
## Description
12
12
13
- This is a style formatting rule. PowerShell is case insensitive where applicable. The casing of
14
- cmdlet names or parameters does not matter but this rule ensures that the casing matches for
15
- consistency and also because most cmdlets/parameters start with an upper case and using that
16
- improves readability to the human eye.
13
+ This is a style/formatting rule. PowerShell is case insensitive wherever possible, so the casing of
14
+ cmdlet names, parameters, keywords and operators does not matter. This rule nonetheless ensures
15
+ consistent casing for clarity and readability. Using lowercase keywords helps distinguish them from
16
+ commands. Using lowercase operators helps distinguish them from parameters.
17
+
18
+ ## How
19
+
20
+ - Use exact casing for type names.
21
+ - Use exact casing of the cmdlet and its parameters.
22
+ - Use lowercase for language keywords and operators.
17
23
18
24
## Configuration
19
25
@@ -28,37 +34,42 @@ Rules = @{
28
34
}
29
35
```
30
36
31
- ### Enable: bool (Default value is ` $false ` )
37
+ ### Parameters
38
+
39
+ #### Enable: bool (Default value is ` $false ` )
32
40
33
41
Enable or disable the rule during ScriptAnalyzer invocation.
34
42
35
- ### CheckCommands: bool (Default value is ` $true ` )
43
+ #### CheckCommands: bool (Default value is ` $true ` )
36
44
37
45
If true, require the case of all operators to be lowercase.
38
46
39
- ### CheckKeyword: bool (Default value is ` $true ` )
47
+ #### CheckKeyword: bool (Default value is ` $true ` )
40
48
41
49
If true, require the case of all keywords to be lowercase.
42
50
43
- ### CheckOperator: bool (Default value is ` $true ` )
51
+ #### CheckOperator: bool (Default value is ` $true ` )
44
52
45
53
If true, require the case of all commands to match their actual casing.
46
54
47
- ## How
48
-
49
- Use exact casing of the cmdlet and its parameters, e.g.
50
- ` Invoke-Command { 'foo' } -RunAsAdministrator ` .
55
+ ## Examples
51
56
52
- ## Example
53
-
54
- ### Wrong
57
+ ### Wrong way
55
58
56
59
``` powershell
60
+ ForEach ($file in Get-childitem -Recurse) {
61
+ $file.Extension -eq '.txt'
62
+ }
63
+
57
64
invoke-command { 'foo' } -runasadministrator
58
65
```
59
66
60
- ### Correct
67
+ ### Correct way
61
68
62
69
``` powershell
70
+ foreach ($file in Get-ChildItem -Recurse) {
71
+ $file.Extension -eq '.txt'
72
+ }
73
+
63
74
Invoke-Command { 'foo' } -RunAsAdministrator
64
75
```
0 commit comments