Today I was asked if it was possible to pull certain time information from a VMware Host to ensure all hosts were not only using the same NTP server but also the same timezone and that they have the same time. Obviously this is something that is very important for a number of reasons including security and auditing.
I sent the following one-liner (broken up here into several for ease of reading) and it was just what was needed.
Get-VMHost | Sort Name | Select Name, ` @{N="NTPServer";E={$_ |Get-VMHostNtpServer}}, ` Timezone, ` @{N="CurrentTime";E={(Get-View $_.ExtensionData.ConfigManager.DateTimeSystem) | Foreach {$_.QueryDateTime().ToLocalTime()}}}, ` @{N="ServiceRunning";E={(Get-VmHostService -VMHost $_ |Where-Object {$_.key-eq "ntpd"}).Running}} ` | Format-Table -AutoSize