Skip to content

Instantly share code, notes, and snippets.

@irlperu
Created May 16, 2019 20:23
Show Gist options
  • Save irlperu/1f76565ece25b4b5ac4d23e465f943c3 to your computer and use it in GitHub Desktop.
Save irlperu/1f76565ece25b4b5ac4d23e465f943c3 to your computer and use it in GitHub Desktop.
Get All Public IP's in Azure Subscription
#Login-AzAccount
Get-AzSubscription
Select-AzSubscription -SubscriptionId SubscriptionIdHere
Get-AzPublicIpAddress | select -Property *name,@{name='sku';e={$_.sku.name}}
# Loop through all Subscriptions that you have access to and export the information
Get-AzSubscription | foreach-object {
Write-Verbose -Message "Changing to Subscription $($_.Name)" -Verbose
$s = Select-AzSubscription -TenantId $_.TenantId -Subscription $_.Id -Force
$Name = $_.Name
$TenantId = $_.TenantId
Get-AzPublicIpAddress | select -Property @{name='subscription';e={$name}}, *name,ipaddress, PublicIpAllocationMethod,location,@{name='sku';e={$_.sku.name}},@{name='dns';e={$_.dnssettings.domainnamelabel}} -OutVariable ra
} | Export-Csv -Path C:\temp\publicipazure.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment