@@ -52,6 +52,7 @@ function Measure-CommandName {
52
52
if ($CommandAst.InvocationOperator -eq " Unknown" ) {
53
53
$CommandName = $CommandAst.CommandElements [0 ].Extent.Text
54
54
$GetCommand = Get-Command $CommandName - ErrorAction SilentlyContinue
55
+ $ActualName = $GetCommand.Name
55
56
if ($null -eq $GetCommand ) {
56
57
# CommandName is not valid.
57
58
# Redo import-module
@@ -74,10 +75,10 @@ function Measure-CommandName {
74
75
}
75
76
return $true
76
77
}
77
- if ($CommandName -cnotmatch " ^([A-Z][a-z]+)+-([A-Z][a-z0-9]*)+$ " ) {
78
+ if ($CommandName -cne $ActualName ) {
78
79
# CommandName doesn't follow the Capitalization Conventions.
79
80
$global :CommandParameterPair += @ {
80
- CommandName = $CommandName
81
+ CommandName = " $CommandName #@# $ActualName "
81
82
ParameterName = " <doesn't follow the Capitalization Conventions>"
82
83
ModuleCmdletExNum = $ModuleCmdletExNum
83
84
}
@@ -108,22 +109,12 @@ function Measure-CommandName {
108
109
$Severity = " Warning"
109
110
}
110
111
if ($global :CommandParameterPair [$i ].ParameterName -eq " <doesn't follow the Capitalization Conventions>" ) {
111
- $Message = " $ ( $CommandParameterPair [$i ].CommandName) doesn't follow the Capitalization Conventions."
112
+ $CommandName , $CorrectName = $CommandParameterPair [$i ].CommandName -split " #@#"
113
+ $Message = " $CommandName doesn't follow the Capitalization Conventions."
112
114
$RuleName = [RuleNames ]::Capitalization_Conventions_Violated
113
115
$RuleSuppressionID = " 5101"
114
- $name = $ ($CommandParameterPair [$i ].CommandName)
115
- $textInfo = (Get-Culture ).TextInfo
116
- $CorrectName = $textInfo.ToTitleCase (($name -split " -" )[0 ])
117
- if ($name -match " Az" ){
118
- $CorrectName += " -Az"
119
- $CorrectName += $textInfo.ToTitleCase (($name -split " Az" )[1 ])
120
- }
121
- else {
122
- $CorrectName += " -"
123
- $CorrectName += $textInfo.ToTitleCase (($name -split " -" )[1 ])
124
- }
125
116
$Remediation = " Check the Capitalization Conventions. Suggest format: $CorrectName "
126
- $Severity = " Warning "
117
+ $Severity = " Error "
127
118
}
128
119
$ModuleCmdletExNum = $ ($CommandParameterPair [$i ].ModuleCmdletExNum)
129
120
$Result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord ]@ {
0 commit comments