Remove-AzNetworkSecurityRuleConfig
Removes a network security rule from a network security group.
Syntax
Default (Default)
Remove-AzNetworkSecurityRuleConfig
[-Name <String>]
-NetworkSecurityGroup <PSNetworkSecurityGroup>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Remove-AzNetworkSecurityRuleConfig cmdlet removes a network security rule configuration from an Azure network security group.
Examples
Example 1: Remove a network security rule configuration
$rule1 = New-AzNetworkSecurityRuleConfig -Name "rdp-rule" -Description "Allow RDP" -Access "Allow" -Protocol "Tcp" -Direction "Inbound" -Priority 100 -SourceAddressPrefix "Internet" -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName "TestRG" -Location "westus" -Name "NSG-FrontEnd" -SecurityRules $rule1
Remove-AzNetworkSecurityRuleConfig -Name "rdp-rule" -NetworkSecurityGroup $nsg
$nsg | Set-AzNetworkSecurityGroup
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. The forth command saves the change.
Parameters
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
Type: | IAzureContextContainer |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Name
Specifies the name of the network security rule configuration that this cmdlet removes.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-NetworkSecurityGroup
Specifies a NetworkSecurityGroup object. This object contains the network security rule configuration to remove.
Parameter properties
Type: | PSNetworkSecurityGroup |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.