i am trying to add a row to all my vms (1000 vms) :
snapshot.maxSnapshots = 4,
i cannot find any script ,Any help is welcome
10x.
Try it like this
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "snapshot.maxSnapshots"
$spec.extraConfig[0].value = 4
Get-VM MyVM | %{$_.ExtensionData.ReconfigVM_Task($spec)}
You can of course update the selection criteria on the Get-VM cmdlet to find the guests you're after.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank u so much!!!, really helped me and did the job for me.
Hi, varonis,
LukeD gave you the correct script. The script is easily generated if you use project Onyx
a tool which enables you to create script while you click on the VSphere Client - like recording macros.
You can read this post -> LINK about which properties to change in order to generate the script you want.
Best regards,
Leni Kirilov
PowerCLI team
Just an FYI, this KB states that you should only be using that parameter under VMWare Technical support guidance.
Out of curiosity, where would one find a reference to these settings?
For all VMX related parameters I start (of course) at the Sanbarrow site.
The snapshot.maxSnapshots can be found there as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nice. Thank Luc.
I know this is an old posting, but I have a quick question for Luc. Do you know if there is a way I can use this script and apply the changes to all host in a cluster?
Maybe using the Get-Cluster cmdlet?
You mean to all VM on all ESXi host in a cluster ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes.
You could do something like this
$clusterName = "My Cluster"
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "snapshot.maxSnapshots"
$spec.extraConfig[0].value = 4
Get-Cluster -Name $clusterName | Get-VM | %{
$_.ExtensionData.ReconfigVM_Task($spec)}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the quick feedback!!
Luc, I ran the command, but unfortunately I ran into my other dilemna. Since you can only connect to a host or VM in PowerCLI, when you issue the command against that cluster it tells you that I'm not connected to a host. Which in reality, even if I connect to a host that probably won't let me run the command against an entire cluster.
Since you mentioned cluster, I assumed you were connecting to a vCenter.
Did you do a Connect-ViServer to the vCenter before running the script ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Newbie mistake, now why didn't I think of that. I got it working now, thanks again!!!
It can be done easier while using
new-advancedsetting or set-advancedsetting, while using -force parameter the New-advancedsetting will override an existing one (so you don't have to use set-advancedsetting)
get-vm test123|new-AdvancedSetting -Name "snapshot.maxSnapshots" -Value "4" -Confirm:$false -Force