VMware Cloud Community
Olivier_Domy
Contributor
Contributor
Jump to solution

Method invocation failed

Hello. I have the following error message "Method invocation failed because http://VMware.Vim.ManagedObjectReference doesn't contain a method named 'UpdateDateTimeConfig'.

At line 29, position 38

$dtsystemMoRef.UpdateDateTimeConfig($dateConfig)". I don't understand because the method exist in the API Reference (http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/index.html).

Please,

could-you help me.

Thx.

bq. My code :

Get-VIServer -Server $VCServer -Protocol $VCProtocol -Port $VCPort -User $VCLogin -Password $VCPassword
"Connection successfull"
$Timezone = "MET"
h6. $hsImpl = Get-VMHost -Name "172.30.8.51"
h6. $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
$dtsystemMoRef.UpdateDateTimeConfig($dateConfig)
"End"

0 Kudos
1 Solution

Accepted Solutions
ykalchev
VMware Employee
VMware Employee
Jump to solution

You should call $dtsystem.UpdateDateTimeConfig($dateConfig) instead of $dtsystemMoRef.UpdateDateTimeConfig($dateConfig) because UpdateDateTimeConfig is a member of HostDateTimeSystem type, not ManagedObjectReference.

Regrads,

Yasen

Yasen Kalchev, vSM Dev Team

View solution in original post

0 Kudos
2 Replies
ykalchev
VMware Employee
VMware Employee
Jump to solution

You should call $dtsystem.UpdateDateTimeConfig($dateConfig) instead of $dtsystemMoRef.UpdateDateTimeConfig($dateConfig) because UpdateDateTimeConfig is a member of HostDateTimeSystem type, not ManagedObjectReference.

Regrads,

Yasen

Yasen Kalchev, vSM Dev Team
0 Kudos
Olivier_Domy
Contributor
Contributor
Jump to solution

OK. It's works. But now, I have another error message :

h6. Exception calling "UpdateDateTimeConfig" with "1" argument(s): "Failed to change host configuration."

At line 29, position 33
h6. $dtsystem.UpdateDateTimeConfig($dateConfig)

Have you any idea?

Thx,

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"

Olivier.

0 Kudos