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)
}
|