Get VM name with specific MAC Address

-Recently I got a request to get a virtual machine (vm) name using only the network interface MAC Address.

After search for some scripts I could not find one that really worked for me so I put my brain to work and this is what I came up:

get-vm | get-networkadapter | Where-Object { $_.macaddress -eq "00:50:56:XX:XX:XX"} | select parent, macaddress

A brief description on how it’s working

get-vm -> gets all VMs on the vSphere server.

get-netwrokadapter -> gets the nertwork adapter properties as name, type, macaddress…

$_.macaddress -eq -> for each networkadapter it is going to compare the MACs and if they are equal it is going to be printed out

The output should be something like this:

55a15d7e5c007131

Performance Graphs

In my current job I have to able to provide on demand all kind of performance charts from the virtual machines through VMware vSphere Client.

While doing this some details caught my attention. I’ll try to explain.

Imagine that you want to take a performance log from one week ago lets say 26/08/2016 from 3:00PM till 5:00PM.

The normal procedure is:

  • Find the machine
  • Choose the Performance Tab and click in Advanced

1BC05B31202E961

  • Chart options

1C1BB7D49E2228A

  • Then you choose the Chart Option and in this case is going to be CPU then Custom with the time frame that we want, the counters Usage and click OK

238D4327292C755

Now you have your graph all ready to present but… what is that? We are missing the first 30 minutes…

$17B7E6516FA45AC6

But the time frame is correct!!!

$6BF810019305C2C0

Well it’s not entirely correct as you can see it starts at 3:00:19 and VMware to save log space from performance logs older than a week only saves in 30 minutes intervals this means that you get a reference point from 30 minutes to 30 minutes and as the log starts at 3:00:19 you don’t get the first reference point.

The only way to solve this as we are unable to choose the seconds when we fill in the custom chart option is to put one minute earlier

$469C264F6E26D6C8

Whit this tweak you’ll get your performance graph correct

$536D45BFBF5B0069

I hope that VMware solves this “problem” and don’t assume the seconds in the performance charts or if so they must be zeroed.