VMware Cloud Community
Jimleslie1977
Contributor
Contributor
Jump to solution

Disbale Synctimewithhostallowed from csv list

Hello, and thanks for any assistance given.

I would like some help forulating a script to refernce a CSV file (list of vm names) in order to disable sync time with host

this is what I have so far but i'm defiatley going wrong somewhere, and maybe way off the mark?

$VC = @("vcenterserver.name")
Connect-VIServer -Server $VC -user "username" -Password password
$v = Import-CSV "C:\Support\VMWare\time2.csv" |
Foreach ($v in (get-vm)) {
$vm = $v | Get-View
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.syncTimeWithHostAllowed = $false
$vm.ReconfigVM($vmConfigSpec)
}

 

again thanks for any help

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Assuming your CSV has a column Name, that contains the name of the VM, you could do

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.syncTimeWithHostAllowed = $false

$VC = @("vcenterserver.name")
Connect-VIServer -Server $VC -User "username" -Password password

Import-Csv "C:\Support\VMWare\time2.csv" |
ForEach-Object -Process {
    $vm = Get-VM -Name $_.Name
    $vm.ExtensionData.ReconfigVM($vmConfigSpec)
}


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Assuming your CSV has a column Name, that contains the name of the VM, you could do

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.syncTimeWithHostAllowed = $false

$VC = @("vcenterserver.name")
Connect-VIServer -Server $VC -User "username" -Password password

Import-Csv "C:\Support\VMWare\time2.csv" |
ForEach-Object -Process {
    $vm = Get-VM -Name $_.Name
    $vm.ExtensionData.ReconfigVM($vmConfigSpec)
}


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

Jimleslie1977
Contributor
Contributor
Jump to solution

Thankyou so much for your help, that was exactly what I needed

Reply
0 Kudos