Check NTP status on numerous ESXi hosts

Automate your work

How to check  NTP status on multiple hosts

 

Simple script

cls
$input = Read-Host “Path for CSV Output”
$AllMembers = @()
foreach($myHost in (Get-VMHost)) {
$serviceStatus = Get-VMHostService $myHost | Where-Object {$\_.key -eq “ntpd”} | select Policy, Running
$myView = Get-View $myHost.Extensiondata.ConfigManager.dateTimeSystem
$ntpServers = Get-VMHostNtpServer $myHost
$allmembers+=new-object psobject -Property @{
Host = $myHost.Name;
StartupPolicy = $serviceStatus.Policy;
Status = $serviceStatus.Running;
ReportedTime = $myView.QueryDateTime();
NTPServers = $ntpservers.ToString();
}
}
$allmembers | Select-Object “Host”, “Status”, “StartupPolicy”, “NTPServers”, “ReportedTime” | export-csv -notypeinformation -path $input

 

 400 total views,  1 views today