We've been having some problems with (certain) VMs losing connectivity to other VMs (i.e., all of a sudden, pings will fail, until I reboot one of the VMs affected). As part of the troubleshooting process, I've been tasked to get a list of all the MAC addresses of the VMs on the specific host that one of these affected VMs is running on. The theory being that maybe the MAC table is corrupt, and Cisco wants to check the MAC addresses of all VMs on that host, with the MAC table on my main core switch.
(personally, I don't think this will resolve the problem, but I have to provide the info as required).
Anyway, there are 3 VMs involved. I have anti-affinity rules in place, so that none of the 3 can be on the same host (i.e., there are separation rules). Additionally, 2 of 3 are on the same subnet, but the 3rd is a different subnet. This means (I think) that packets have to leave the VMhost, go to the Cisco switch, and get routed back to a different VMhost.
So, since I know what 3 VMs are affected, what I need to do is:
Determine which VMhost each VM is running on.
Then, determine the list of all VMs that are running on the above host.
Then compile a list of all the IP address/MAC addresses of those VMs..
Repeat for each of the 3 VMs affected.
This will give me the MAC address of my 3 VMs (I will adapt as necessary, of course):
ForEach($vm in Get-VM){
$vm.Guest.Nics | ForEach{
$row = "" | Select Name, IP, MAC, NetworkName
$row.Name = $vm.Name
$row.IP = [string] $_.IPAddress
$row.MAC = $_.MacAddress
$row.NetworkName = $_.NetworkName
$IPaddresses += $row
}
}
But how do I determine what VMHost they are running on? And then what VMs are on that host?
Thanks for any pointers