Here is a Powershell script that will set NTP on all the ESX host connected to your vCenter.
First connect to the vCenter using Connect-VIserver then run the following code.
#Get Host
write-host “Gathering ESX Host”
$esx = get-vmhost#Configure NTP server
write-host “configuring NTP”
Add-VmHostNtpServer -VMHost $esx -NtpServer 10.10.16.220#Allow NTP queries outbound through the firewall
wrtie-host “Setting Firewall Permissions”
Get-VMHostFirewallException -VMHost $esx | where {$_.Name -eq “NTP client”} | Set-VMHostFirewallException -Enabled:$true#Start NTP client service and set to automatic
write-host “Starting NTP service”
Get-VmHostService -VMHost $esx | Where-Object {$_.key -eq “ntpd”} | Start-VMHostService
Get-VmHostService -VMHost $esx | Where-Object {$_.key -eq “ntpd”} | Set-VMHostService -policy “automatic”
Recent Comments