Highlighted
Contributor
Contributor

How to set Configuration Parameters for all VMs in vCenter 6.0

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Highlighted
User Moderator
User Moderator

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

View solution in original post

0 Kudos
10 Replies
Highlighted
User Moderator
User Moderator

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.

0 Kudos
Highlighted
Contributor
Contributor

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

0 Kudos
Highlighted
VMware Employee
VMware Employee

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.

0 Kudos
Highlighted
Contributor
Contributor

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

0 Kudos
Highlighted
User Moderator
User Moderator

Discussion moved from VMware vCenter™ to VMware PowerCLI

0 Kudos
Highlighted
User Moderator
User Moderator

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

View solution in original post

0 Kudos
Highlighted
Contributor
Contributor

LucD that code looks very promising, I will test in next day or so.  Thank you!


Michael

0 Kudos
Highlighted
VMware Employee
VMware Employee

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

      }

}


0 Kudos
Highlighted
Contributor
Contributor

LucD and Jterli,

Thank you both for the scripts, I am all set now!

Michael

0 Kudos
Highlighted
Contributor
Contributor
incase you have vCenter with cluster setup:
Get-Cluster ClusterName | Get-VM | New-AdvancedSetting -Name "isolation.tools.paste.disable" -value "false" -Confirm:$false
Get-Cluster ClusterName | Get-VM | New-AdvancedSetting -Name "isolation.tools.copy.disable" -value "false" -Confirm:$false
0 Kudos