Quit3Simpl3
Quit3Simpl3

Reputation: 313

How to get Hyper-V VM's IP address with Powershell?

I'm trying to acquire my VM's IP address using this code:

$vm.NetworkAdapters | Select-Object IPAddresses

The output is:

IPAddresses
-----------
{}
{}
{}

For some reason, I can't get back the IP addresses of the VM... It's up and running and it has network connection.

Upvotes: 1

Views: 6403

Answers (2)

Quit3Simpl3
Quit3Simpl3

Reputation: 313

Okay so apparently running this does work:

get-vm | select -ExpandProperty networkadapters | select vmname, macaddress, switchname, ipaddresses

But first I had to install Linux Integration Services on my Ubuntu machine: 1. Run:

# sudo apt-get update
# sudo apt-get install linux-azure

choose y (yes) when prompted.

  1. Run:

    # reboot

Thanks everyone for your help

Upvotes: 6

Richard Siddaway
Richard Siddaway

Reputation: 451

The Hyper-V VM has to be running for the IP address information to be available. If your VM is running try this

Get-VM -Name W19ND01 | 
select -ExpandProperty NetworkAdapters | 
select VMname, Name, IPAddresses

Upvotes: 1

Related Questions