Home > Scripting, VMware > Configure NTP on Multiple Hosts Using PowerShell

Configure NTP on Multiple Hosts Using PowerShell

August 11th, 2009 Eric Leave a comment Go to comments

A handy script to correct NTP settings on multiple hosts.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#Usage: Get-VMHost | .\ConfigureNtpServer.ps1
 
BEGIN
{
    $ntpServers = @("ntpserver01","ntpserver02")
 
    $hostDateTimeConfig = New-Object Vmware.Vim.HostDateTimeConfig 
    $hostNtpConfig = New-Object VMware.Vim.HostNtpConfig 
    $hostDateTimeConfig.ntpConfig = $hostNtpConfig 
    $hostDateTimeConfig.ntpConfig.server = $ntpServers
}
 
 
PROCESS
{
    $vmHost = $_
    $vmHostView = Get-View $vmHost.ID
    $dateTimeSystem =  $vmHostView.ConfigManager.DateTimeSystem 
    $DateTimeSystemRef = Get-View  $dateTimeSystem
    $DateTimeSystemRef.updateDateTimeConfig($hostDateTimeConfig)
}
Categories: Scripting, VMware Tags:
  1. No comments yet.
  1. No trackbacks yet.

Switch to our mobile site