Search This Blog

Friday, April 6, 2012

An Easy way to get VMhost UUID

I saw a blog for getting a VMhost UUID.  UUID is sometimes needed. In my case I needed it to license EMC Powerpath VE.

There's a an easy way than going through all that.

Get-VMhost | Get-View | % { $_.hardware.systeminfo.uuid }

That's it. If you want to get fancy and have a need for speed (if you have many VMhosts):

Get-View -ViewType HostSystem -Propert Name, hardware.systeminfo -Filter @{"Name"="VMHostNameHere" }  | % { $_.hardware.systeminfo.uuid }

If you want to get even fancier and return the host name with the UUID, here's a little trick using SELECT:

Get-View -ViewType HostSystem -Propert Name, hardware.systeminfo -Filter @{"Name"="VMHostNameHere" }  | Select Name, @{N="UUID" ; E={$_.hardware.systeminfo.uuid } }

Notice the "N=" and "E=" clauses? N means NAME and E means expression.

No offense to . Visit it, It's a nice blog.