VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot
Jump to solution

Get VMs that sync time with host

Hello,

I need to Get VMs that sync time with host, and also disable this feature to force VMs to sync against the configured NTP server on the OS level.

Thank you,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

To disable that you can do

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.tools = New-Object VMWare.Vim.ToolsConfigInfo

$spec.tools.syncTimeWithHost = $false


Get-VM |

where{$_.ExtensionData.Config.Tools.syncTimeWithHost} |

ForEach-Object -Process {

   $_.ExtensionData.ReconfigVM($spec)

}

To set the NTP configuration inside your guest OS, depends on which guest OS you are running.

You can do that part via Invoke-VMScript


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

To disable that you can do

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.tools = New-Object VMWare.Vim.ToolsConfigInfo

$spec.tools.syncTimeWithHost = $false


Get-VM |

where{$_.ExtensionData.Config.Tools.syncTimeWithHost} |

ForEach-Object -Process {

   $_.ExtensionData.ReconfigVM($spec)

}

To set the NTP configuration inside your guest OS, depends on which guest OS you are running.

You can do that part via Invoke-VMScript


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

0 Kudos
Saeidmoradi68
Contributor
Contributor
Jump to solution

Hi. I can't run this command in powercli. how can run for all vm in vcenter in powercli. 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That "I can't run this command" is a bit vague I'm afraid.


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

0 Kudos
system_noida
Enthusiast
Enthusiast
Jump to solution

Hi @LucD ,

 

How can i import a Csv file to disable the time sync setting with host for some specific VMs.

Please can you help me.

 

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.tools = New-Object VMWare.Vim.ToolsConfigInfo

$spec.tools.syncTimeWithHost = $false


Get-VM |

where{$_.ExtensionData.Config.Tools.syncTimeWithHost} |

ForEach-Object -Process {

   $_.ExtensionData.ReconfigVM($spec)

}

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Assuming you have a CSV with a column named Name, you could do

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.tools = New-Object VMWare.Vim.ToolsConfigInfo
$spec.tools.syncTimeWithHost = $false

$vms = Import-Csv -Path .\vms.csv -UseCulture
Get-VM -Name $vms.Name |
where{$_.ExtensionData.Config.Tools.syncTimeWithHost} |
ForEach-Object -Process {
   $_.ExtensionData.ReconfigVM($spec)
}


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

0 Kudos