Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Unable to fetch IP address on Hyper-V guest with Get-SCVirtualNetworkAdapter

As you can see, the Hyper-V guest has IP addresses on two interfaces:
 User generated image

I try to fetch one specific one:
(Get-SCVirtualNetworkAdapter -VM $ComputerName | where  {$_.VLanID -eq "127"})

From this I get no Ip-addresses:
User generated image
The VMM manager also shows no IP-addresses for this nic:
User generated image
But VMM has no problem showing the IP address of the other nic:
User generated image
And if I use Powershell and fetch the other NIC by its VLAN I get the IP address no problem:
(Get-SCVirtualNetworkAdapter -VM $ComputerName | where  {$_.VLanID -eq "118"})
User generated image

I need the IP via powershell for NIC in VLAN 127 on the hyper-v guest. Any ideas?
Avatar of Shabarinath TR
Shabarinath TR
Flag of India image

Hi Itnifl,

I just tried this commandlet on my lab and works perfectly well.
I tested it agnist a test vm with two different network interface with different VLAN ID. I could get the IP Address based on the VLAN which I mention on the Where condition.

My lab has SCVMM 2012 R2 with RU3 and Windows server 2012 R2 as the Hypervisor.

Could you please let me know the version and Rollup on your SCVMM ?

Cheers!
Shaba
Also, VMM should fetch this ip address and details automatically. As your screenshot for connection details dosent shows any information, you need to concentrate on that first. Could you please try refreshing the VM and see if refresh is getting successfully completed. If you added the second interface recently, it may take some time for VMM to refresh automatically and get that information.

See if connection details is getting the IP address as expected after a successful refresh.

Good luck !
Avatar of itnifl

ASKER

Using Microsoft System Center 2012 R2
VMM 3.2.7672.0 with Update Rollup 3
Hosts are Microsoft Server 2012 R2 Datacenter
VMM agent is 3.2.7510.0 - verified on all hosts.

Before I answer your second post I would like to add that the code that fetches this information failed again tonight with the exception: Exception of type 'System.OutOfMemoryException' was thrown.

The code waits in an eternal loop until the IP address is fetched, and I assume that this crashed after several hours of running. Howver when I logged on this morning and ran the code manually via my powershell window, the IP address was shown as it was supposed to. But the strange thing is that when I logged on to the VMM console and checked what was being shown in VMM, the NIC with VLAN 127 was no longer there. It was removed this morning by one of our other administrators. So why does the powershell cmdlets run on the VMM server tell me that the VM has a NIC with IP xx.xx.xx.xx in VLAN 127? Is there caching happening somewhere that is not  being flushed? Do I need to reconnect to VMM or something?

So I made a new VM and tried out the powershell string to getch IP of nic in VLAN 127, and sure again, I get no IP. The Connection details in VMM show also no IP like described in the question. I right click the VM and choose refresh, then right click and choose proprties, then navigate to the NIC in VLAN 127, but still no IP information is shown.

I decide to power off and boot the VM. But that has no effect. I logged in on the VM and changed the ip configuration NIC to have a static address and set a address, but still no information of this showing up in VMM or via powershell. Refreshed the host, and all virtual machines on the jost, no result. Checking the jobs history I can see that the 'Refresh virtual machine properties' job was successful.

After all this I migrated the VM between all the hosts and checked the IP information via VMM and powershell.
Host 1, 2 and 5 had the same problem,
I could not migrate to host 3 and 4, getting the error:
Error (10698)
The virtual maxhine (namehere) could not be live migrated to the virtual machine host (host name here) using this cluster configuration

Recommended Action:
Check the cluster configuration and try the operation again.
Might just be that these hosts have the lowest ratings of the hosts in the cluster? When checking the cluster properties and then status everything is green, except ClusterValidation tests that says "Succeeded with warning." Checking the report of that test, I see it is immensely long and for the most after glancing over it part shows irrelevant warnings like noticing that a VM is powered off.

I removed the NIC in VLAN 127 and re added it, getting the same problem with showing IPs. Removed it and this time powrshell actually shows no information regarding the nic as it is supposed to, in contrast to what I described earlier.
ASKER CERTIFIED SOLUTION
Avatar of Shabarinath TR
Shabarinath TR
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

I did not find the solutioin this way, but I think there is no better way to go.
Possibly the integration service on the vm are not running properly, or I can add the nic with an static IP via vmm. That way VMM will always know about the IP of the NIC. See https://www.experts-exchange.com/questions/28511406/How-to-use-New-SCVirtualNetworkAdapter-cmdlet-to-set-a-static-IP-address.html

Or I could talk to the DHCP server with the DHCPServer cmdlets to get the IP from there:
(Get-DhcpServerv4Lease -scopeid 192.6.4.0 -ComputerName dhcpServer| where {$_.hostname -like "ServerName*"}).IPAddress.toString()

Open in new window