Skip to content

New-NetworkSecurityGroup

Azure: Creates a network security group

param(
	[Parameter(Mandatory = $true)]
	[string]$ResourceGroupName,

	[Parameter(Mandatory = $true)]
	[string]$Name,

	[Parameter(Mandatory = $true)]
	[string]$Location
)

try {
	Import-Module Az.Network -ErrorAction Stop
	$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroupName -Name $Name -Location $Location -ErrorAction Stop
	Write-Output $nsg
} catch {
	Write-Error $_
	exit 1
}

The name of the resource group.

The name of the network security group.

The Azure region where the resource will be created.

An interactive directory of PowerShell scripts.