Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove-VMScaleSetDebuggerNatPools
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