1
votes

I need to disable some rules configured under network security groups with RDP and SSH port open. I am facing some issues with removing the rule configuration :

This is the command I execute :

Get-AzureRmNetworkSecurityGroup -Name $securityGroupName -ResourceGroupName $resourceGroupName | Remove-AzureRmNetworkSecurityRuleConfig -Name $enabledSecurityRDPRule.Name

However when I check the portal or execute the get cmdlet I don't see the earlier command took effect.

I even tried with Set-AzureRmNetworkSecurityRuleConfig to set the access to deny and got the same result.

The service principal that I use to access my environment has contributor privileges.

1

1 Answers

0
votes

The Remove-AzureRmNetworkSecurityRuleConfig command just removes the rule from your local NSG object. In order to sync the cloud side, you need to run the Set-AzureRmNetworkSecurityGroup.

Here is a complete script.

$nsg = Get-AzureRmNetworkSecurityGroup -Name <your nsg name> `
                  -ResourceGroupName <your resource group name>

$nsg = Remove-AzureRmNetworkSecurityRuleConfig -Name <your rule name> `
                  -NetworkSecurityGroup $nsg

Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $nsg