Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function Remove-VMScaleSetDebuggerNatPools {
param (
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)
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