Remove-AzureRmNetworkSecurityRuleConfig

Removes a network security rule from a network security group.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

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:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
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
Required:False
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
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

PSNetworkSecurityGroup

Parameters: NetworkSecurityGroup (ByValue)

Outputs

PSNetworkSecurityGroup