Set-AzureRmNetworkSecurityGroup

Sets the goal state for a network security group.

Syntax

Set-AzureRmNetworkSecurityGroup
   -NetworkSecurityGroup <PSNetworkSecurityGroup>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Set-AzureRmNetworkSecurityGroup cmdlet sets the goal state for an Azure network security group.

Examples

Example 1: Set the goal state for a network security group

PS C:\>Get-AzureRmNetworkSecurityGroup -Name "Nsg1" -ResourceGroupName "Rg1" | Add-AzureRmNetworkSecurityRuleConfig -Name "Rdp-Rule" -Description "Allow RDP" -Access "Allow" -Protocol "Tcp" -Direction "Inbound" -Priority 100 -SourceAddressPrefix "Internet" -SourcePortRange "*" -DestinationAddressPrefix "*" -DestinationPortRange "3389" | Set-AzureRmNetworkSecurityGroup

This command gets the Azure network security group named Nsg1, and adds a network security rule named Rdp-Rule to allow Internet traffic on port 3389 to the retrieved network security group object using Add-AzureRmNetworkSecurityRuleConfig. The command persists the modified Azure network security group using Set-AzureRmNetworkSecurityGroup.

Required Parameters

-NetworkSecurityGroup

A network security group object representing the goal state to which the cmdlet sets the network security group.

Type:Microsoft.Azure.Commands.Network.Models.PSNetworkSecurityGroup
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional 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

Inputs

PSNetworkSecurityGroup

Parameter 'NetworkSecurityGroup' accepts value of type 'PSNetworkSecurityGroup' from the pipeline

Outputs

Microsoft.Azure.Commands.Network.Models.PSNetworkSecurityGroup