Skip to content

Instantly share code, notes, and snippets.

@jsiegmund
Created July 26, 2018 09:44
Show Gist options
  • Save jsiegmund/f904f29e32f7f262b291a1bd961a4d86 to your computer and use it in GitHub Desktop.
Save jsiegmund/f904f29e32f7f262b291a1bd961a4d86 to your computer and use it in GitHub Desktop.
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