Modify NTP servers on ESXi hosts: Difference between revisions
From VVCWiki
Jump to navigationJump to search
Created page with "<source lang="powershell"> $hosts = get-vmhost foreach ($server in $hosts) { write-host $server $oldntps = Get-VMHostNtpServer -VMHost $server foreach ($ntp in $oldntps)..." |
(No difference)
|
Latest revision as of 15:50, 29 November 2013
$hosts = get-vmhost
foreach ($server in $hosts)
{
write-host $server
$oldntps = Get-VMHostNtpServer -VMHost $server
foreach ($ntp in $oldntps)
{
Remove-VmHostNtpServer -NtpServer $ntp -VMHost $server -Confirm:$false
}
Add-VmHostNtpServer -NtpServer "10.70.32.3" -VMHost $server
Add-VmHostNtpServer -NtpServer "10.70.10.3" -VMHost $server
Add-VmHostNtpServer -NtpServer "192.168.254.107" -VMHost $server
Get-VmHostService -VMHost $server | Where-Object {$_.key -eq "ntpd"} | Restart-VMHostService -Confirm:$false
}