@@ -52,6 +52,7 @@ function Measure-CommandName {
5252 if ($CommandAst.InvocationOperator -eq " Unknown" ) {
5353 $CommandName = $CommandAst.CommandElements [0 ].Extent.Text
5454 $GetCommand = Get-Command $CommandName - ErrorAction SilentlyContinue
55+ $ActualName = $GetCommand.Name
5556 if ($null -eq $GetCommand ) {
5657 # CommandName is not valid.
5758 # Redo import-module
@@ -74,10 +75,10 @@ function Measure-CommandName {
7475 }
7576 return $true
7677 }
77- if ($CommandName -cnotmatch " ^([A-Z][a-z]+)+-([A-Z][a-z0-9]*)+$ " ) {
78+ if ($CommandName -cne $ActualName ) {
7879 # CommandName doesn't follow the Capitalization Conventions.
7980 $global :CommandParameterPair += @ {
80- CommandName = $CommandName
81+ CommandName = " $CommandName #@# $ActualName "
8182 ParameterName = " <doesn't follow the Capitalization Conventions>"
8283 ModuleCmdletExNum = $ModuleCmdletExNum
8384 }
@@ -108,22 +109,12 @@ function Measure-CommandName {
108109 $Severity = " Warning"
109110 }
110111 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."
112114 $RuleName = [RuleNames ]::Capitalization_Conventions_Violated
113115 $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- }
125116 $Remediation = " Check the Capitalization Conventions. Suggest format: $CorrectName "
126- $Severity = " Warning "
117+ $Severity = " Error "
127118 }
128119 $ModuleCmdletExNum = $ ($CommandParameterPair [$i ].ModuleCmdletExNum)
129120 $Result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord ]@ {
0 commit comments