As you saw in the previous post, missing ntp configuration on one the vSphere hosts burnt me. I did not want to go through 30 some hosts manually, so decided to bulk update the ntp configuration on all my hosts. After a quick google search i found SnowVM blog post on this.

Here is the commands for my own quick reference.

Connect-VIServer vCenterServerFQDNorIP
Get-VMHost | Add-VMHostNtpServer NTPServerFQDNorIP
Get-VMHost | Get-VMHostFirewallException | where {$_.Name -eq "NTP client"} | Set-VMHostFirewallException -Enabled:$true
Get-VMHost | Get-VmHostService | Where-Object {$_.key -eq "ntpd"} | Start-VMHostService
Get-VMhost | Get-VmHostService | Where-Object {$_.key -eq "ntpd"} | Set-VMHostService -policy "automatic"

One response to “Set NTP on vSphere hosts via PowerCLI”

  1. Hicham Avatar
    Hicham

    Works perfectly, thnx

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.