Bulk Edit NTP servers in vSphere using PowerCLI

Props to the following blog on these steps.  He did a great write up.
Bulk configure NTP for vSphere hosts using PowerCLI

Whether you need to bulk edit or enable NTP on your hosts the following script will do the job through PowerCLI

First connect to your vcenter using PowerCLI.  Once that is done run the following lines of code.  Replace time1 and time2 with appropriate IP or fully qualified names for your domain.  This will set the NTP server and start the services.

Get-VMHost | Add-VMHostNtpServer time1-FQDN
Get-VMHost | Add-VMHostNtpServer time2-FQDN
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”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s