Skip to content

Commit 33be72a

Browse files
Merge pull request microsoft#495 from srdan-bozovic-msft/master
Update to ConvertCidrToUint32Array
2 parents 212fc03 + 2c48769 commit 33be72a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

samples/manage/azure-sql-db-managed-instance/attach-jumpbox/attachJumpbox.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ function SetVirtualNetwork
112112
function ConvertCidrToUint32Array
113113
{
114114
param($cidrRange)
115-
$cidrRangeParts = $cidrRange.Split(@(".","/"))
116-
$ipnum = ([Convert]::ToUInt32($cidrRangeParts[0]) -shl 24) -bor `
117-
([Convert]::ToUInt32($cidrRangeParts[1]) -shl 16) -bor `
118-
([Convert]::ToUInt32($cidrRangeParts[2]) -shl 8) -bor `
119-
[Convert]::ToUInt32($cidrRangeParts[3])
120-
121-
$maskbits = [System.Convert]::ToInt32($cidrRangeParts[4])
115+
$cidrRangeParts = $cidrRange.Split("/")
116+
$ipParts = $cidrRangeParts[0].Split(".")
117+
$ipnum = ([Convert]::ToUInt32($ipParts[0]) -shl 24) -bor `
118+
([Convert]::ToUInt32($ipParts[1]) -shl 16) -bor `
119+
([Convert]::ToUInt32($ipParts[2]) -shl 8) -bor `
120+
[Convert]::ToUInt32($ipParts[3])
121+
122+
$maskbits = [System.Convert]::ToInt32($cidrRangeParts[1])
122123
$mask = 0xffffffff
123124
$mask = $mask -shl (32 -$maskbits)
124125
$ipstart = $ipnum -band $mask
@@ -208,4 +209,4 @@ $templateParameters = @{
208209

209210
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri ($scriptUrlBase+'/azuredeploy.json?t='+ [DateTime]::Now.Ticks) -TemplateParameterObject $templateParameters
210211

211-
Write-Host "Deployment completed."
212+
Write-Host "Deployment completed."

0 commit comments

Comments
 (0)