Hi,
I've been using this script to set the timesync of a VM to TRUE. But I can't seem to set it to false.
Connect-VIServer [http://Reflection.Assembly|http://Reflection.Assembly]::LoadWithPartialName("vmware.vim") $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo $vmConfigSpec.Tools.syncTimeWithHost = "TRUE" Get-VM -name "VMWSV339" | % { (Get-View $_.ID).ReconfigVM($vmConfigSpec)}
I thought that changing TRUE to FALSE would do the trick, but it doesn't.....
Why not?
Message was edited by: halr9000 ** reformatted code with tags
Hi,
The value which you are setting in property is string while it is expecting this value in boolean. Please chenge the line of code as below and try it.
$vmConfigSpec.Tools.syncTimeWithHost = $false // For false
$vmConfigSpec.Tools.syncTimeWithHost = $true // For true
Thanks
Niket
Hi,
The value which you are setting in property is string while it is expecting this value in boolean. Please chenge the line of code as below and try it.
$vmConfigSpec.Tools.syncTimeWithHost = $false // For false
$vmConfigSpec.Tools.syncTimeWithHost = $true // For true
Thanks
Niket
With PowerShell you have to use $true or $false for boolean properties.
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo $vmConfigSpec.Tools.syncTimeWithHost = $false Get-VM -name "VMWSV339" | % { (Get-View $_.ID).ReconfigVM($vmConfigSpec)}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Note that once you perform a connection using connect-viserver, the [http://VMware.Vim|http://VMware.Vim] namespace is loaded into your session. You don't need to load it manually.
PowerShell MVP, VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org