In this article, I’ll walk you through multiple proven methods to retrieve both public and private IP addresses of Azure VMs using PowerShell, using a simple PowerShell script, and the Azure Portal.
Table of Contents
Get Azure VM IP address PowerShell
Before diving into the specific commands, let’s consider why PowerShell is often the preferred approach for retrieving Azure VM IP addresses:
- Automation: Integrate IP retrieval into your deployment scripts and CI/CD pipelines
- Bulk operations: Get IPs for multiple VMs simultaneously
- Filtering: Easily target specific VMs or resource groups
- Output customization: Format results exactly as needed
- Cross-platform support: Works with PowerShell 7 across Windows, macOS, and Linux
Prerequisites
Below are the Prerequisites required before starting.
- PowerShell 5.1 or later (PowerShell 7+ recommended)
- Azure PowerShell module installed
- An active Azure subscription
- Appropriate permissions to view VM resources
If you haven’t set up the Azure PowerShell module yet, install it with:
Install-Module -Name Az -Repository PSGallery -ForceOnce installed, connect to your Azure account:
Connect-AzAccountAssuming you are ready with the above Prerequisites, let us start with the functionality.
Approach 1: Using a PowerShell script
You can easily retrieve the IP address of your Azure Virtual Machine using PowerShell using the below PowerShell script.
$vmdetailsreport = @()
$vmList = get-azurermvm
$vmnic = get-azurermnetworkinterface | ?{ $_.VirtualMachine -NE $null}
foreach($nic in $vmnic)
{
$details = "" | Select VmName, ResourceGroupName, HostName, IpAddress
$myvm = $vmList | ? -Property Id -eq $nic.VirtualMachine.id
$details.VMName = $myvm.Name
$details.ResourceGroupName = $myvm.ResourceGroupName
$details.IpAddress = $nic.IpConfigurations.PrivateIpAddress
$details.HostName = $myvm.OSProfile.ComputerName
$vmdetailsreport+=$details
}After executing the above query, I got the expected output as shown in the screenshot below.

Approach 2: Using Azure Portal
To get Public IP address of Azure VM, follow the steps below.
- Log in to the Azure Portal (https://portal.azure.com/)
- Once you log in to the Azure Portal, Search for the Virtual Machine.

3. Once you click on the search result in Virtual Machines, you can see all your virtual machines listed below. Click on the specific virtual machine for which you want to check the IP address.

4. On the Virtual machine page, you can see the Public IP address highlighted below.

You can also click on the Networking option from the left navigation on the Virtual Machine page. You can see the Public and private IP addresses for the virtual machine as highlighted below.

5. By default, the IP address of the Azure Virtual Machine is dynamic. If you want to change the dynamic IP of the VM to a Static IP address, you can click on the IP address, as highlighted below.

6. Now, in the window below, change the Assignment option from Dynamic to Static and click the Save button to save the changes. Now, the IP address of your Azure Virtual Machine has become Static.

FAQs
Does Virtual Machine have its own IP address?
The answer is yes, virtual machines are similar to physical computers. A virtual machine can have one or more IP addresses. The IP address can be public or private. When discussing IP addresses in the context of Virtual Machines, they are closely associated with the network interfaces. Again, the Network interfaces with the Network adapters.
Final Thoughts
Retrieving Azure VM IP addresses using PowerShell is a fundamental skill for cloud administrators and DevOps engineers. Whether you’re managing a small environment or a large one, the methods mentioned in this article provide flexible, efficient approaches to accessing this critical information.
By mastering these approaches as mentioned in this article, you’ll be well-equipped to integrate IP address retrieval into your broader Azure automation workflows, saving time and reducing manual errors.
In this Azure article, we discussed the quick steps to get the IP address of your Azure Virtual Machine. Thanks for reading this article !!!
You may also like the following articles below
- How to Create an Azure VM (Virtual Machine)
- Azure virtual machine DNS (FQDN)
- How to access Azure VM (Virtual Machine)
- How to reset the password in an Azure virtual machine
- Azure VM backup step by step

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
