Find what your Guest OS is on an ESX cluster

This is done on Windows, using Powershell and the VI Toolkit.

First you have to connect to the server

Connect-VIServer localhost

Now run the command

get-vm | %{
$vm = "" | Select Name, OSFullname
$vm.Name = $_.Name
$guest = $_ | Get-VMGuest
$vm.OSFullName = $guest.OSFullName
$vm
}

The output will have a windows return character (/r) you need to be aware of. I opened the file in TextWrangler and saved it again to get rid of it, but that’s not an ideal solution. This will not show you the OS of hosts that are down, but that’s OK for now.

EDIT – This should work

tr -d '\r' < your_file > new_file