VMware Cloud Community
HX5
Enthusiast
Enthusiast
Jump to solution

Edit "Sync guest time with host" on several VMs by PowerCLI

Hi folks,

In my vSphere Cluster (Version 5.1) I have about 70 VMs in a resource pool called "RP_nonProd".

Now I need to enable "Sync guest time with host" on all those VM in the mentioned resource pool.

I have figured out, that with the following command:

Get-ResourcePool | Where {$_.Name -ne “Resources“ }| Select Name, @{N=“NumVM“;E={($_ | Get-VM).Count}} | Sort Name

I am able to get a coma separated list of all VMs in the resource pool. Unfortunately, I don't know which command allows me edit "Sync guest time with host" over PowerCLI.

I know, that there's an object called "$spec.tools.syncTimeWithHost = $true" which you can set to true, but I don't know, how to write a simple script with this function.

So any help will be gratefully accepted.

Regards'

Marc

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

$VMS = Get-VM -Location (Get-ResourcePool YourResourcePool)

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec 
$spec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$spec.Tools.syncTimeWithHost = $true
$VMS
| %{   $_.ExtensionData.ReconfigVM($spec) }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

$VMS = Get-VM -Location (Get-ResourcePool YourResourcePool)

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec 
$spec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$spec.Tools.syncTimeWithHost = $true
$VMS
| %{   $_.ExtensionData.ReconfigVM($spec) }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
HX5
Enthusiast
Enthusiast
Jump to solution

Hi LucD

Thank you for helping me out with this... It worked like a charm...

Have a nice day.

Regards'

Marc

0 Kudos