Created
July 26, 2018 09:44
-
-
Save jsiegmund/f904f29e32f7f262b291a1bd961a4d86 to your computer and use it in GitHub Desktop.
Remove-VMScaleSetDebuggerNatPools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-VMScaleSetDebuggerNatPools { | |
param ( | |
[string]$ResourceGroupName, | |
[string]$VMScaleSetName | |
) | |
Write-Information "Removing NAT pools with 'debugger' in the name from VM scale set $VMScaleSetName" | |
$vmScaleSet = Get-AzureRmVmss -ResourceGroupName $ResourceGroupName -VMScaleSetName $VMScaleSetName | |
$natPools = $vmScaleSet.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.ipConfigurations.LoadBalancerInboundNatPools | |
$debugPools = $natPools | Where-Object { $_.Id -match "Debugger" } | |
foreach ($debugPool in $debugPools) | |
{ | |
$natPools.Remove($debugPool) | |
} | |
if ($debugPools.Count -lt 0) | |
{ | |
Write-Information "Updating $VMScaleSetName to save the changes" | |
Update-AzureRmVmss -ResourceGroupName $ResourceGroupName -VMScaleSetName $VMScaleSetName -VirtualMachineScaleSet $vmScaleSet | |
} else | |
{ | |
Write-Information "Skipping updates on $VMScaleSetName, no debugger pools found." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment