All scripts
Azure AI 485
Get-AzurePublicIPInventory
Lists every public IP address in the subscription, what resource it is attached to (or unattached), and its SKU, useful for catching unused public IPs that are still costing money.
Get-AzurePublicIPInventory.ps1
<#
.SYNOPSIS
Inventories public IP addresses across the subscription.
.DESCRIPTION
Lists every public IP address resource with what it is attached to,
or flags it as unattached, since an unattached public IP still costs
money and is easy to lose track of after a resource is deleted.
.EXAMPLE
.\Get-AzurePublicIPInventory.ps1
.NOTES
Requires the Az.Network module and an active Connect-AzAccount session.
.AUTHOR
Shehryar Hassan
#>
$ips = Get-AzPublicIpAddress
$report = $ips | Select-Object Name, ResourceGroupName, IpAddress, Sku,
@{N="Attached";E={[bool]$_.IpConfiguration}},
@{N="AttachedTo";E={ if ($_.IpConfiguration) { ($_.IpConfiguration.Id -split "/")[-3] } else { "Unattached" } }}
$report | Format-Table -AutoSize
$unattached = $report | Where-Object { -not $_.Attached }
Write-Warning "$($unattached.Count) unattached public IP address(es) still provisioned."
Read it before you run it, and test in a safe tenant first.