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,35 +10,58 @@ title: UseCorrectCasing
10
10
11
11
## Description
12
12
13
- This is a style/formatting rule. PowerShell is case insensitive wherever possible,
14
- so the casing of cmdlet names, parameters, keywords and operators does not matter.
15
- This rule nonetheless ensures consistent casing for clarity and readability.
16
- Using lowercase keywords helps distinguish them from commands.
17
- Using lowercase operators helps distinguish them from parameters.
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.
18
17
19
18
## How
20
19
21
- Use exact casing for type names.
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.
22
23
23
- Use exact casing of the cmdlet and its parameters, e.g.
24
- ` Invoke-Command { 'foo' } -RunAsAdministrator ` .
24
+ ## Configuration
25
25
26
- Use lowercase for language keywords and operators.
26
+ ``` powershell
27
+ Rules = @{
28
+ PS UseCorrectCasing = @{
29
+ Enable = $true
30
+ CheckCommands = $true
31
+ CheckKeyword = $true
32
+ CheckOperator = $true
33
+ }
34
+ }
35
+ ```
36
+
37
+ ### Parameters
38
+
39
+ #### Enable: bool (Default value is ` $false ` )
40
+
41
+ Enable or disable the rule during ScriptAnalyzer invocation.
42
+
43
+ #### CheckCommands: bool (Default value is ` $true ` )
27
44
28
- ## Example
45
+ If true, require the case of all operators to be lowercase.
29
46
30
- ### Wrong
47
+ #### CheckKeyword: bool (Default value is ` $true ` )
48
+
49
+ If true, require the case of all keywords to be lowercase.
50
+
51
+ #### CheckOperator: bool (Default value is ` $true ` )
52
+
53
+ If true, require the case of all commands to match their actual casing.
54
+
55
+ ## Examples
56
+
57
+ ### Wrong way
31
58
32
59
``` powershell
33
- ForEach ($file IN get-childitem -recurse) {
34
- $file.Extension -Eq '.txt'
35
- }
60
+ invoke-command { 'foo' } -runasadministrator
36
61
```
37
62
38
- ### Correct
63
+ ### Correct way
39
64
40
65
``` powershell
41
- foreach ($file in Get-ChildItem -Recurse) {
42
- $file.Extension -eq '.txt'
43
- }
66
+ Invoke-Command { 'foo' } -RunAsAdministrator
44
67
```
0 commit comments