Add Rules to NSG in Azure

In continuation to Create NSG in Azure about adding rules to NSG


# Variables
$RGName = "user-fiahxmxusscf"
$Region = "eastus"
$port=3389 
$rulename="Allow-RDP" 
$nsgname="sf-vnet-security"
$NICName = "nic2"

# Get the NSG resource 
$nsg = Get-AzNetworkSecurityGroup -Name $nsgname -ResourceGroupName $RGname 

# Add the inbound security rule. 
$nsg | Add-AzNetworkSecurityRuleConfig -Name $rulename -Description "Allow RDP" -Access Allow ` -Protocol * -Direction Inbound -Priority 3891 -SourceAddressPrefix "*" -SourcePortRange * ` -DestinationAddressPrefix * -DestinationPortRange $port

# Update the NSG. 
$nsg | Set-AzNetworkSecurityGroup

references:

Subscribe to NordLetter

A weekly newsletter on living in Finland.

UPDATED