Hello, I try to set NTP on ESX server 3.5. My VC is 2.5. I start with a script in FAQ but it doesn't work. I have the following message :
bq. h6. Exception calling "UpdateDateTimeConfig" with "1" argument(s): "Failed to change host configuration."
At line 31, position 33
$dtsystem.UpdateDateTimeConfig($dateConfig)
I trap to handle error with trap command. After, I have no error messages but my NTP is not set.
My code :
h6. Get-VIServer -Server $VCServer -Protocol $VCProtocol -Port $VCPort -User $VCLogin -Password $VCPassword
"Connection successfull"
$Timezone = "MET"
$hsImpl = Get-VMHost -Name "172.30.8.51"
$hs = Get-View $hsImpl.ID
$dtsystemMoRef = $hs.ConfigManager.DateTimeSystem
$dtsystem = Get-View $dtsystemMoRef
$dateConfig = New-Object Vmware.Vim.HostDateTimeConfig
$hsntpConfig = New-Object VMware.Vim.HostNtpConfig
$dateConfig.ntpConfig = $hsntpConfig
$dateConfig.ntpConfig.server = @("172.30.4.236")
$dateConfig.timeZone = $Timezone
$dtsystem.UpdateDateTimeConfig($dateConfig)
"End"
Please, could you help me?
I think that your time zone value is invalid. You can query available time zones using $dtsystem.QueryAvailableTimeZones() and pass the value of the Key property to $dateConfig.timeZone
Regards,
Yasen
I think that your time zone value is invalid. You can query available time zones using $dtsystem.QueryAvailableTimeZones() and pass the value of the Key property to $dateConfig.timeZone
Regards,
Yasen
The method fails indeed on the MET timezone.
Although this seems to be one of the accepted timezones (see directory /usr/share/zoneinfo on the ESX server) the method doesn't seem to accept this value.
The QueryAvailableTimeZones method doesn't return this key either.
If you give for example "Europe/Paris" all is well.
Btw you can not see the timezone from the VI Client, check the file /etc/sysconfig/clock on the ESX server.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It's works. Wonderfull. Thanks a lot
My code :
h6. Get-VIServer -Server $VCServer -Protocol $VCProtocol -Port $VCPort -User $VCLogin -Password $VCPassword
$Timezone = "Europe/Paris"
$hsImpl = Get-VMHost -Name "172.30.8.51"
$hs = Get-View $hsImpl.ID
$dtsystemMoRef = $hs.ConfigManager.DateTimeSystem
$dtsystem = Get-View $dtsystemMoRef
$dateConfig = New-Object Vmware.Vim.HostDateTimeConfig
$hsntpConfig = New-Object VMware.Vim.HostNtpConfig
$dateConfig.ntpConfig = $hsntpConfig
$dateConfig.ntpConfig.server = @("172.30.4.236")
$dateConfig.timeZone = $Timezone
$dtsystem.UpdateDateTimeConfig($dateConfig)