Check NTP status on numerous ESXi hosts

Automate your work

How to check  NTP status on multiple hosts


Simple script

$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



Please Comment and Subscribe


Leave a Reply

Your email address will not be published. Required fields are marked *