Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Torxsmind/e5d48fbe2ae05f2508d2ccc6dcddfd41 to your computer and use it in GitHub Desktop.

Select an option

Save Torxsmind/e5d48fbe2ae05f2508d2ccc6dcddfd41 to your computer and use it in GitHub Desktop.
Get all Azure Public IPs from all subscriptions that the current in user has access to.
$now = Get-Date -UFormat "%Y-%m-%d_%H-%M-%S"
$filepath = 'C:\temp\Azure_PIP_export_' + $now + '.csv'
$subs = Get-AzSubscription
foreach ($sub in $subs) {
Select-AzSubscription -Subscription $sub.Name
Get-AzPublicIpAddress `
| Select-Object -Property Name, ResourceGroupName, IpAddress, `
@{label='FQDN';expression={$_.DnsSettings.Fqdn}}, `
@{label='ID';expression={$_.IPConfiguration.ID}} `
| Export-Csv -Path $filepath -NoTypeInformation -Append
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment