Skip to content

Get-NetworkSecurityGroupSummaryReport

Azure: Gets a summary report of network security groups

param(
	[Parameter(Mandatory = $false)]
	[string]$ResourceGroupName
)

try {
	Import-Module Az.Network -ErrorAction Stop
	
	[hashtable]$cmdArgs = @{ 'ErrorAction' = 'Stop' }
	if ($ResourceGroupName) { $cmdArgs.Add('ResourceGroupName', $ResourceGroupName) }

	$nsgs = Get-AzNetworkSecurityGroup @cmdArgs | Select-Object Name, ResourceGroupName, Location, @{N='RuleCount'; E={$_.SecurityRules.Count}}
	Write-Output $nsgs
} catch {
	Write-Error $_
	exit 1
}

The name of the resource group (optional).

An interactive directory of PowerShell scripts.