How to Delete Multiple Azure Public IPs with Azure PowerShell

In this article, we will show you how to do delete multiple Azure Public IPs using Azure PowerShell.

Azure Public IPs are essential for hosting applications or services in Azure. They allow communication with the public internet and provide a way to access resources from the outside. However, there may come a time when you need to delete multiple Public IPs in your Azure subscription.

The first step is to connect to your Azure account using Azure PowerShell. You can do that by running the following command:


This will prompt you to enter your Azure credentials. Once you have entered your credentials, you will be connected to your Azure account.

Select the Subscription

The next step is to select the Azure subscription that contains the Public IPs you want to delete. You can do that using the following command:

select-AzSubscription -SubscriptionName "subscription name"

Delete Public IPs

The code below will delete 3 public IPs that are in the $ipAddressesToDelete object. To get a list of Public IPs in your subscription, run the following cmdlet.

Get-AzPublicIpAddress | select name, IpAddress, ResourceGroupName

# code starts here

$resourceGroupName = "rg-name"
$ipAddressesToDelete = @("ipname1","ipname2", "ipname3")

# Iterate through the IP addresses and delete each one

foreach ($ipAddress in $ipAddressesToDelete) {
 $ipToDelete = Get-AzPublicIpAddress -Name $ipAddress -     
  ResourceGroupName $resourceGroupName

Remove-AzPublicIpAddress -Name $ipAddress -ResourceGroupName  
 $resourceGroupName -Force
Write-Output "Deleted IP address $($ipToDelete.Name)."






Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.