From 7cc631b378ef240e60c04c7fd07322d88c85a9af Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 24 Mar 2021 11:26:05 +0100 Subject: [PATCH] Fix switch regex match --- scripts/Update-OvfConfiguration.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/Update-OvfConfiguration.ps1 b/scripts/Update-OvfConfiguration.ps1 index 07908fa..c0fc01f 100644 --- a/scripts/Update-OvfConfiguration.ps1 +++ b/scripts/Update-OvfConfiguration.ps1 @@ -128,13 +128,13 @@ ForEach ($Category in $OVFConfig.PropertyCategories) { $XMLPropertyAttrKey.Value = $Property.Key $XMLPropertyAttrType = $XML.CreateAttribute('type', $XML.DocumentElement.ovf) Switch -regex ($Property.Type) { - 'boolean' { + '^boolean' { $XMLPropertyAttrType.Value = 'boolean' } - 'int' { + '^int' { $XMLPropertyAttrType.Value = 'uint8' $Qualifiers = @() - If ($Property.Type -match 'int\((\d*)\.\.(\d*)\)') { + If ($Property.Type -match '^int\((\d*)\.\.(\d*)\)') { If ($Matches[1]) { $Qualifiers += "MinValue($($Matches[1]))" } @@ -146,20 +146,20 @@ ForEach ($Category in $OVFConfig.PropertyCategories) { [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers) } } - 'ip' { + '^ip' { $XMLPropertyAttrType.Value = 'string' $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.vmw) $XMLPropertyAttrQualifiers.Value = 'Ip' [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers) } - 'password' { + '^password' { $XMLPropertyAttrType.Value = 'string' $XMLPropertyAttrPassword = $XML.CreateAttribute('password', $XML.DocumentElement.ovf) $XMLPropertyAttrPassword.Value = 'true' [void]$XMLProperty.Attributes.Append($XMLPropertyAttrPassword) $Qualifiers = @() - If ($Property.Type -match 'password\((\d*)\.\.(\d*)\)') { + If ($Property.Type -match '^password\((\d*)\.\.(\d*)\)') { If ($Matches[1]) { $Qualifiers += "MinLen($($Matches[1]))" } @@ -171,10 +171,10 @@ ForEach ($Category in $OVFConfig.PropertyCategories) { [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers) } } - 'string' { + '^string' { $XMLPropertyAttrType.Value = 'string' $Qualifiers = @() - If ($Property.Type -match 'string\((\d*)\.\.(\d*)\)') { + If ($Property.Type -match '^string\((\d*)\.\.(\d*)\)') { If ($Matches[1]) { $Qualifiers += "MinLen($($Matches[1]))" } @@ -184,7 +184,7 @@ ForEach ($Category in $OVFConfig.PropertyCategories) { $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf) $XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' ' [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers) - } ElseIf ($Property.Type -match 'string\[(.*)\]') { + } ElseIf ($Property.Type -match '^string\[(.*)\]') { $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf) $XMLPropertyAttrQualifiers.Value = "ValueMap{$($Matches[1] -replace '","', '", "')}" [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)