Update to ConvertCidrToUint32Array

Mitigation for cloud shell string split issue
This commit is contained in:
Srđan Božović
2018-11-27 13:41:27 +01:00
committed by GitHub
parent 212fc038f2
commit 2c48769866
@@ -112,13 +112,14 @@ function SetVirtualNetwork
function ConvertCidrToUint32Array
{
param($cidrRange)
$cidrRangeParts = $cidrRange.Split(@(".","/"))
$ipnum = ([Convert]::ToUInt32($cidrRangeParts[0]) -shl 24) -bor `
([Convert]::ToUInt32($cidrRangeParts[1]) -shl 16) -bor `
([Convert]::ToUInt32($cidrRangeParts[2]) -shl 8) -bor `
[Convert]::ToUInt32($cidrRangeParts[3])
$cidrRangeParts = $cidrRange.Split("/")
$ipParts = $cidrRangeParts[0].Split(".")
$ipnum = ([Convert]::ToUInt32($ipParts[0]) -shl 24) -bor `
([Convert]::ToUInt32($ipParts[1]) -shl 16) -bor `
([Convert]::ToUInt32($ipParts[2]) -shl 8) -bor `
[Convert]::ToUInt32($ipParts[3])
$maskbits = [System.Convert]::ToInt32($cidrRangeParts[4])
$maskbits = [System.Convert]::ToInt32($cidrRangeParts[1])
$mask = 0xffffffff
$mask = $mask -shl (32 -$maskbits)
$ipstart = $ipnum -band $mask
@@ -208,4 +209,4 @@ $templateParameters = @{
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri ($scriptUrlBase+'/azuredeploy.json?t='+ [DateTime]::Now.Ticks) -TemplateParameterObject $templateParameters
Write-Host "Deployment completed."
Write-Host "Deployment completed."