Instantly share code, notes, and snippets.

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