There are some VM Configuration parameters that I want to force down to all virtual machines in my vcenter. How could I do this without making changes VM by VM.
Michael
Try something like this
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$opt1 = New-Object VMware.Vim.OptionValue
$opt1.Key = 'tools.syncTime'
$opt1.Value = 0
$spec.ExtraConfig += $opt1
$opt2 = New-Object VMware.Vim.OptionValue
$opt2.Key = 'time.synchronize.continue'
$opt2.Value = 0
$spec.ExtraConfig += $opt2
$opt3 = New-Object VMware.Vim.OptionValue
$opt3.Key = 'time.synchronize.restore'
$opt3.Value = 0
$spec.ExtraConfig += $opt3
$opt4 = New-Object VMware.Vim.OptionValue
$opt4.Key = 'time.synchronize.resume.disk'
$opt4.Value = 0
$spec.ExtraConfig += $opt4
$opt5 = New-Object VMware.Vim.OptionValue
$opt5.Key = 'time.synchronize.shrink'
$opt5.Value = 0
$spec.ExtraConfig += $opt5
$opt6 = New-Object VMware.Vim.OptionValue
$opt6.Key = 'time.synchronize.tools.startup'
$opt6.Value = 0
$spec.ExtraConfig += $opt6
$opt7 = New-Object VMware.Vim.OptionValue
$opt7.Key = 'time.synchronize.tools.enable'
$opt7.Value = 0
$spec.ExtraConfig += $opt7
$opt8 = New-Object VMware.Vim.OptionValue
$opt8.Key = 'time.synchronize.resume.host'
$opt8.Value = 0
$spec.ExtraConfig += $opt8
foreach($vmName in Get-Content -Path vmnames.txt){
$vm = Get-VM -Name $vmName
$vm.ExtensionData.ReconfigVM($spec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think that the easiest way to achieve this is by running a PowerCLI script.
You can find several examples for VM modifications in the PowerCLI community. If you cannot find what you are looking for, let us know what you want to change.
André
PS: If you want, I can move your question to the PowerCLI community.
Andre I want to totally disable time sync between VMs and hosts, see KB article below.
Disabling Time Synchronization (1189) | VMware KB
I have 850 VMs in my environment so doing this one by one would be a good amount of work.
PowerCli is fine, was hoping I could use Advanced Settings off the vcenter instance in the web client to push down the change.
Michael
The below powercli script might help.
Connect-VIServer -Server "servername" -User "username" -Password "password"
$vms = Get-VM
foreach($vm in $vms) {
Get-VM -Name $vm.Name | Get-AdvancedSetting -Name "config parameter name" | Set-AdvancedSetting -value "value" -Confirm:$false
}
You can provide the values for the servername, username, password, config parameter name and value to the script.
It might fail when the vm is powered on as few configuration parameters cannot be set in VM powered on state.
JTERLI or any other scripter,
These are the parameters
tools.syncTime = "0"
time.synchronize.continue = "0"
time.synchronize.restore = "0"
time.synchronize.resume.disk = "0"
time.synchronize.shrink = "0"
time.synchronize.tools.startup = "0"
time.synchronize.tools.enable = "0"
time.synchronize.resume.host = "0"
Would it be possible to provide me with a powercli script that I can feed in a list VMs in a text file that will add the above parameters settings to the VM? My scripting skills are weak at best.
Regards,
Michael
Discussion moved from VMware vCenter™ to VMware PowerCLI
Try something like this
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$opt1 = New-Object VMware.Vim.OptionValue
$opt1.Key = 'tools.syncTime'
$opt1.Value = 0
$spec.ExtraConfig += $opt1
$opt2 = New-Object VMware.Vim.OptionValue
$opt2.Key = 'time.synchronize.continue'
$opt2.Value = 0
$spec.ExtraConfig += $opt2
$opt3 = New-Object VMware.Vim.OptionValue
$opt3.Key = 'time.synchronize.restore'
$opt3.Value = 0
$spec.ExtraConfig += $opt3
$opt4 = New-Object VMware.Vim.OptionValue
$opt4.Key = 'time.synchronize.resume.disk'
$opt4.Value = 0
$spec.ExtraConfig += $opt4
$opt5 = New-Object VMware.Vim.OptionValue
$opt5.Key = 'time.synchronize.shrink'
$opt5.Value = 0
$spec.ExtraConfig += $opt5
$opt6 = New-Object VMware.Vim.OptionValue
$opt6.Key = 'time.synchronize.tools.startup'
$opt6.Value = 0
$spec.ExtraConfig += $opt6
$opt7 = New-Object VMware.Vim.OptionValue
$opt7.Key = 'time.synchronize.tools.enable'
$opt7.Value = 0
$spec.ExtraConfig += $opt7
$opt8 = New-Object VMware.Vim.OptionValue
$opt8.Key = 'time.synchronize.resume.host'
$opt8.Value = 0
$spec.ExtraConfig += $opt8
foreach($vmName in Get-Content -Path vmnames.txt){
$vm = Get-VM -Name $vmName
$vm.ExtensionData.ReconfigVM($spec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD that code looks very promising, I will test in next day or so. Thank you!
Michael
The below code can help :
$parameters = @{"tools.syncTime" = 0; "time.synchronize.continue" = 0; "time.synchronize.restore" = 0; "time.synchronize.resume.disk" = 0;
"time.synchronize.shrink" = 0; "time.synchronize.tools.startup" = 0; "time.synchronize.tools.enable" = 0; "time.synchronize.resume.host" = 0}
$vms = Get-VMHost -Name "hostname" | get-vm
foreach($vm in $vms)
{
foreach($param in $parameters.Keys)
{
$vm | New-AdvancedSetting -Name $param -Value $parameters.Item($param) -Confirm:$false
#$vm | Get-AdvancedSetting -Name $param | Remove-AdvancedSetting -Confirm:$false
}
}
LucD and Jterli,
Thank you both for the scripts, I am all set now!
Michael