Skip to content

Instantly share code, notes, and snippets.

@yooakim
Last active August 25, 2022 07:41
Show Gist options
  • Save yooakim/33eac1fe3b543af0d78d6d4a19c4bfe9 to your computer and use it in GitHub Desktop.
Save yooakim/33eac1fe3b543af0d78d6d4a19c4bfe9 to your computer and use it in GitHub Desktop.
Simple PowerShell + AZ CLI to get public IP addresse from all subscriptions I have access to
$Subscriptions = az account list --query '[].{Id:id,Name:name,TenantId:tenantId}' | ConvertFrom-Json
$PublicIPs=$Subscriptions | % { az network public-ip list --query '[].{Name:name,PublicIP:ipAddress,Version:publicIpAddressVersion,Method:publicIpAllocationMethod,SKU:sku.name,ResourceGroup:resourceGroup,DNS:dnsSettings.fqdn,d:id}' --subscription $_.Id -o json | ConvertFrom-Json }
$PublicIPs | select Name,PublicIP, ResourceGroup, SKU, Version, Method | Sort-Object Name | Format-Table -AutoSize
$PublicIPs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment