NTP Update PoSH for ESX

NTP Update PoSH for ESX

$Cluster = "<cluster name>"
$Hosts = Get-Cluster $Cluster | Get-VMHost
ForEach ($Host in $Hosts)
{
Remove-VmHostNtpServer -NtpServer "x.x.x.x" -VMHost $Host | Out-Null
Remove-VmHostNtpServer -NtpServer "x.x.x.x" -VMHost $Host | Out-Null
Add-VmHostNtpServer -NtpServer "ntp0.sysxperts.com" -VMHost $Host | Out-Null
Add-VmHostNtpServer -NtpServer "ntp1.sysxperts.com" -VMHost $Host | Out-Null
Get-VMHostService -VMHost $Host | Where-Object {$_.key -eq "ntpd"} | Restart-VMHostService Confirm:$false | Out-Null
write "NTP Server was changed on $host"
}

No comments: