Last active
July 26, 2018 09:44
-
-
Save jsiegmund/b64c128062eb46d0e6b39a41bc500052 to your computer and use it in GitHub Desktop.
Remove-LoadBalancerDebuggerNatPools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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