imompero
Enthusiast
Enthusiast

New-advancedsetting setting is slow...any suggestions?

I am trying to change some log rotate settings on VMs, I have about 1500 vms to modify.  I found the script below, it works but does so very slowly.  Any suggestions to speed things up?

$parameters = @{"log.keepOld" = 10; "log.rotatesize" = 1024000}

$vms = get-vm *test*

foreach($vm in $vms){

   foreach($param in $parameters.Keys){

          $vm | New-AdvancedSetting -Name $param -Value $parameters.Item($param) -Confirm:$false -force

          }

}

0 Kudos
1 Reply
LucD
Leadership
Leadership

Instead of calling the New-AdvancedSetting once for each setting you want to change, you can use the ReconfigVM method, and change all settings for 1 VM in 1 call.

And direct API method calls tend to be faster than the cmdlet most of the time.

Let me know if you need an example?


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

0 Kudos