If you want to configure a hosts NTP server list through PowerCLI you have a few cmdlet at your disposal.

  • Get-VMHostNtpServer
  • Remove-VMHostNtpServer
  • Add-VMHostNtpServer
  • Get-VMHostService
  • Set-VMHostService
  • Get-VmhostFirewallException
  • Restart-VMHostService

Get a list of NTP servers on a host.

Get-VMHostNtpServer -VMHost "esx01.lab.local"

To remove a specific NTP server from a host NTP server list.

Remove-VMHostNtpServer -VMHost "esx01.lab.local" -NtpServer '127.127.1.0' -Confirm:$false

To remove all NTP servers on a hosts NTP server list.

$arrNTPList = Get-VMHostNtpServer -VMHost "esx01.lab.local"
Remove-VMHostNtpServer -VMHost "esx01.lab.local" -NtpServer $arrNTPList -Confirm:$false

To add a single NTP server to a hosts NTP server list.

Add-VMHostNtpServer -VMHost "esx01.lab.local" -NtpServer "dk.pool.ntp.org" -Confirm:$false

To add a a list of NTP servers to a hosts NTP server list.

$arrNTPServers = ("dk.pool.ntp.org","de.pool.ntp.org","us.pool.ntp.org")
Add-VMHostNtpServer -VMHost "esx01.lab.local" -NtpServer $arrNTPServers -Confirm:$false

To set the NTP deamon (service) to start automatic.

Set-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost "esx01.lab.local") | Where-Object {$_.key -eq "ntpd"}) -Policy "Automatic"

Open firewall to allow the NTP deamon to communicate with the NTP server.

Get-VmhostFirewallException -VMHost "esx01.lab.local" -Name "NTP Client" | Set-VMHostFirewallException -enabled:$true

To restart the NTP deamon (service) after you have configured it – without restarting the host.

$ntpd = Get-VMHostService -VMHost "esx01.lab.local" | where {$_.Key -eq 'ntpd'}
Restart-VMHostService $ntpd -Confirm:$false