PowerShell Genie

Az.Network module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect Azure virtual networks, subnets, NSGs and public IPs with Az.Network while keeping resource group, region and object IDs explicit.

Getting it

Install-PSResource -Name Az.Network from the PowerShell Gallery.

Examples

1PS> Get-AzVirtualNetwork
Show reference output
1 Name ResourceGroupName Location AddressSpace
2 ---- ----------------- -------- ------------
3 vnet-prod RG-PROD eastus {10.20.0.0/16}
1PS> Get-AzNetworkInterface
Show reference output
1 Name ResourceGroupName Location Primary ProvisioningState
2 ---- ----------------- -------- ------- -----------------
3 web01-nic RG-PROD eastus True Succeeded

What it is for

Use it for NSG rule audits and for tracing which subnet a workload actually sits in. It is also the module for public IP discovery, which tends to be the first step in an internet exposure review.

Typical tasks

  • Inventory virtual networks and address space
  • Export NSG rules for review
  • Find public IP addresses in a subscription
  • Map network interfaces back to their VMs
  • Read effective security rules on a NIC
  • Review peering state between two VNets

Check the installed version

1PS> Get-Module -ListAvailable Az.Network | Select-Object Name, Version, Path
2PS> Get-Command -Module Az.Network

Compare the module path and version with the session used by your scheduled task or automation account. Use it for NSG rule audits and for tracing which subnet a workload actually sits in. It is also the module for public IP discovery, which tends to be the first step in an internet exposure review.

Primary documentation

Windows services and processes documentation

Continue
Genie guideAz.Network module: setup and commands

Inspect Azure virtual networks, subnets, NSGs and public IPs with Az.Network while keeping resource group, region and object IDs explicit.