4 Simple Steps to Get IP Addresses of All VMs in Hyper-V

Managing virtual machines (VMs) on the Hyper-V platform can sometimes feel overwhelming for system administrators. However, identifying the IP addresses of VMs doesn’t have to be one of those challenges. Whether you need to export IP details, identify VM owners, or locate an available IP address, this step-by-step guide will make your task a breeze.

In this tutorial, we’ll leverage PowerShell’s Hyper-V module and its powerful Get-VM cmdlet to fetch the IP addresses of all VMs on a Hyper-V host. Let’s dive in!

Step 1: Open PowerShell with Administrator Privileges

To start, open a PowerShell console in administrator mode. This ensures that you have the required permissions to execute Hyper-V-related commands.

Step 2: Check Available Properties Using Get-Member

The Get-VM cmdlet retrieves details about all VMs on the host. To explore its properties, enter the following command:

Get-VM | Get-Member

This will display a list of properties available for VMs. One particularly useful property is NetworkAdapters, which contains details about each VM’s network configuration.

Step 3: Filter Network Details with Select-Object

Using the NetworkAdapters property, you can extract key details about each VM’s IP configuration. Run the following command:

Get-VM | Select-Object -ExpandProperty NetworkAdapters

To further refine the output and display specific details like the VM name, IP addresses (IPv4/IPv6), and the connected virtual switch, use:

Get-VM | Select-Object -ExpandProperty NetworkAdapters | Select-Object VMName, IPAddresses, SwitchName

Step 4: Use an Alternative Command for Network Details

An alternative approach is to directly utilize the Get-VMNetworkAdapter cmdlet, which simplifies the process:

Get-VM | Get-VMNetworkAdapter | Format-Table VMName, IPAddresses, SwitchName

This command outputs a neatly formatted table showing the VM name, its associated IP addresses, and the virtual switch to which it is connected.

Key Notes:

These commands rely on the integration services installed on your VMs. Whether the VM is running Windows or Linux, the IP address should be returned.

Ensure that the virtual machine is powered on; otherwise, the IP address will not be retrievable.

Have Other Commands to Share?

If you know additional PowerShell commands or methods to fetch VM details, share them with us in the comments! At host.co.in, we are committed to simplifying server and hosting management for professionals like you.