Skip to content

Instantly share code, notes, and snippets.

@andreaswasita
Created November 7, 2014 03:12
Show Gist options
  • Save andreaswasita/6f57990746e36f9240f6 to your computer and use it in GitHub Desktop.
Save andreaswasita/6f57990746e36f9240f6 to your computer and use it in GitHub Desktop.
#Create a Network Security Group
New-AzureNetworkSecurityGroup -Name "DMZ_NSG" -Location Southeast Asia -Label "DMZ NSG SEVNET"
#Add, Update Rules to a NSG
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Set-AzureNetworkSecurityRule -Name RDPInternet-DMZ -Type Inbound -Priority 347 -Action Allow -SourceAddressPrefix 'INTERNET' -SourcePortRange '63389' -DestinationAddressPrefix '10.0.2.0/25' -DestinationPortRange '63389' -Protocol TCP
#Delete a rule from NSG
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Remove-AzureNetworkSecurityRule -Name RDPInternet-DMZ
#Associate a NSG to a Virtual machine
Get-AzureVM -ServiceName "Proxy01" -Name "azproxy01" | Set-AzureNetworkSecurityGroupConfig -NetworkSecurityGroupName "DMZ_NSG"
#Remove a NSG from a VM
Get-AzureVM -ServiceName "Proxy01" -Name "azproxy01" | Remove-AzureNetworkSecurityGroupConfig -NetworkSecurityGroupName "DMZ_NSG"
#Associate a NSG to a subnet
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Set-AzureNetworkSecurityGroupToSubnet -VirtualNetworkName 'SEVNET' -SubnetName 'Azure DMZ Subnet'
#Remove a NSG from the subnet
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Remove-AzureNetworkSecurityGroupFromSubnet -VirtualNetworkName 'SEVNET' -SubnetName 'Azure DMZ Subnet'
#Delete a NSG
Remove-AzureNetworkSecurityGroup -Name "DMZ_NSG"
#Get Details of Network Secuirty group along with rules
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" -Detailed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment