Remove-AzureRmNetworkSecurityRuleConfig

Removes a network security rule from a network security group.

Important

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, we'll retire AzureRM PowerShell modules on 29 February 2024.

To avoid service interruptions, update your scripts that use AzureRM PowerShell modules to use Az PowerShell modules by 29 February 2024. To automatically update your scripts, follow the quickstart guide.

Syntax

Remove-AzureRmNetworkSecurityRuleConfig
      [-Name <String>]
      -NetworkSecurityGroup <PSNetworkSecurityGroup>
      [-DefaultProfile <IAzureContextContainer>]
      [<CommonParameters>]

Description

The Remove-AzureRmNetworkSecurityRuleConfig cmdlet removes a network security rule configuration from an Azure network security group.

Examples

Example 1: Remove a network security rule configuration

PS C:\>$rule1 = New-AzureRmNetworkSecurityRuleConfig -Name "rdp-rule" -Description "Allow RDP" -Access "Allow" -Protocol "Tcp" -Direction "Inbound" -Priority 100 -SourceAddressPrefix "Internet" -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
PS C:\> $nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName "TestRG" -Location "westus" -Name "NSG-FrontEnd" -SecurityRules $rule1
PS C:\> Remove-AzureRmNetworkSecurityRuleConfig -Name "rdp-rule" -NetworkSecurityGroup $nsg

The first command creates a network security rule configuration named rdp-rule, and then stores it in the $rule1 variable. The second command creates a network security group using the rule in $rule1, and then stores the network security group in the $nsg variable. The third command removes the network security rule configuration named rdp-rule from the network security group in $nsg.

Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Name

Specifies the name of the network security rule configuration that this cmdlet removes.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-NetworkSecurityGroup

Specifies a NetworkSecurityGroup object. This object contains the network security rule configuration to remove.

Type:PSNetworkSecurityGroup
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

Inputs

PSNetworkSecurityGroup

Parameters: NetworkSecurityGroup (ByValue)

Outputs

PSNetworkSecurityGroup