Skip to content

Instantly share code, notes, and snippets.

@jsiegmund
Last active July 26, 2018 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsiegmund/b64c128062eb46d0e6b39a41bc500052 to your computer and use it in GitHub Desktop.
Save jsiegmund/b64c128062eb46d0e6b39a41bc500052 to your computer and use it in GitHub Desktop.
Remove-LoadBalancerDebuggerNatPools
function Remove-LoadBalancerDebuggerNatPools
{
param(
[string]$ResourceGroupName,
[string]$LoadBalancerName
)
Write-Information "Removing NAT pools with 'debugger' in the name from load balancer $LoadBalancerName"
$loadBalancer = Get-AzureRmLoadBalancer -Name $LoadBalancerName -ResourceGroupName $resourceGroupName
$pools = $loadBalancer.InboundNatPools | Where-Object { $_.Name -match "debugger" }
foreach ($pool in $pools) {
$loadBalancer.InboundNatPools.Remove($pool)
}
if ($pools.Count -lt 0)
{
Write-Information "Updating $LoadBalancerName to save the changes"
Set-AzureRmLoadBalancer -LoadBalancer $loadBalancer
}
else {
Write-Information "Skipping updates on $LoadBalancerName, no debugger pools found."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment