VMware Cloud Community
Gabrie1
Commander
Commander
Jump to solution

Can set to True but not to False

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

http://www.GabesVirtualWorld.com
0 Kudos
1 Solution

Accepted Solutions
Niket
Enthusiast
Enthusiast
Jump to solution

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

View solution in original post

0 Kudos
4 Replies
Niket
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Gabrie1
Commander
Commander
Jump to solution

Thanks... life can be so simple

http://www.GabesVirtualWorld.com
0 Kudos
halr9000
Commander
Commander
Jump to solution

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

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos