Posts

Showing posts from July, 2013

PowerCLI Script to Edit ESXi Host NTP Settings

Here's another quick one.  A customer of mine recently had to change their NTP settings across every ESXi host in their environment.  Given that they have a lot of clusters with different storage and network settings, host profiles didn't seem to be the best solution available.  Fortunately, PowerCLI has a few nice easy cmdlets to make life easier.  After a bit of quality time on google and the PowerCLI Cmdlet Reference Page, I was able to put together the following quick script.  It goes through every ESXi host in the environment, removes all configured NTP servers, adds whatever servers are specified in the $NTPServers array, sets the service to "on" (this site had some inconsistent configurations there) and restarts the service to ensure that the settings take effect.

If you want to make use of any of this, just change the variables near the top to be a list of your NTP Servers of choice.  If you want to limit the scope of the script, you can change the $AllHosts …