I have Hyper-V on Windows Server 2012, and in the Hyper-v I have CentOS 6/7 vm. I doing the following command:
Get-vm -name "x" | select -ExpandProperty NetworkAdaptersOutput:
Name IsManagementOs VMName SwitchName MacAddress Status IPAddresses
---- -------------- ------ ---------- ---------- ------ -----------
Network Adapter False "x" InternalSwitch Mac {Degraded, protocolversion} {}Why is IPAddresses empty?
I tried (command).ipaddresses and got the same result.
3 Answers
I had to install Linux Integration Services to the virtual machine (Linux Integration Services 4.1):
- Download the package from Linux Integration Services Version 4.1 for Hyper-V to the guest server (Linux) and unpack it. There is also an ISO image available that you can mount with Hyper-V Manager if you have no way of transferring the package to the guest host.
- Find your distribution under the unpacked directory (e.g.
CentOS72). - Run
install.shas root. - Reboot the guest OS.
For CentOS 7 it also required to disable NetworkManager. That (and other hints) is told in Supported CentOS and Red Hat Enterprise Linux virtual machines on Hyper-V (Notes 2 for NetworkManager)
Run: systemctl disable NetworkManager and reboot
Now the Hyper-V Manager should show you the IP address of the VM and Get-VM should also work.
You're not alone here, I have this issue too. Make sure that you're running PowerShell as admin, or you wouldn't get any IP addresses at all. And even if it run as admin, I still can get IP address only for one VM out of 30 on my host.
I could not solve this issue using PowerShell tools, but there is a workaround:
You can get the MAC address of your VM with Get-VMNetworkAdapter. From the Hyper-V host, ping the IP address range you know you VM can get (from DHCP I suppose), and test the ARP table for the MAC address.