Skip navigation
VMware

This Question is Answered (go to answer)

1 "helpful" answer available (6 pts)
198 Views 4 Replies Last post: Nov 24, 2008 6:09 AM by halr9000 RSS
Gabrie Master vExpert 1,079 posts since
Jun 6, 2005
Currently Being Moderated

Nov 24, 2008 5:49 AM

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?

 

 

http://www.GabesVirtualWorld.com

 

Message was edited by: halr9000 ** reformatted code with  tags

Niket Hot Shot VMware Employees 91 posts since
Jan 10, 2008
Currently Being Moderated
1. Nov 24, 2008 4:35 AM in response to: Gabrie
Re: Can set to True but not to False

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

LucD Guru User Moderators vExpert 8,981 posts since
Oct 31, 2005
Currently Being Moderated
2. Nov 24, 2008 4:36 AM in response to: Gabrie
Re: Can set to True but not to False

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: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
halr9000 Master vExpert 1,124 posts since
Jun 7, 2007
Currently Being Moderated
4. Nov 24, 2008 6:09 AM in response to: Gabrie
Re: Can set to True but not to False

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

Bookmarked By (0)

Share This Page

Communities