There are currently no methods of controlling the number of VMware snapshots using vCenter or ESX(i) permissions today, you either provide the snapshot privilege or you deny it all together. I recently discovered an undocumented .vmx entry that allows you to control the maximum number of VMware snapshots for a given virtual machine. By default, a virtual machine can have a snapshot tree depth of 31, in the worse case scenario supporting up to a maximum of 496 snapshots.
Here is what a VM looks like with 496 snapshots (unexpanded):
Note: If you are interested in what this looks like fully expanded, take a look at the screenshot at the very bottom of this post.
If you like to prevent the above or at least control the maximum number of snapshots for a given virtual machine, you can add the following into a VM's .vmx configuration file. Ideally, this is deployed using vSphere API as there is no need to directly edit the VMX's file and this can also be applied to a live running VM (another benefit of using the vSphere API).
Here is an example using PowerCLI:
$vm = Get-VM -Name TestVM
New-AdvancedSetting -Name snapshot.maxSnapshots -Value 1 -Entity $vm
For those that prefer using another vSphere SDK, you just need to use the ReconfigVM_Task() to add the VM Advanced Setting. Please take a look at this sample for here for how to add/update VM Advanced Settings.
snapshot.maxSnapshots = "n"
where n = max number of snapshots and n <= 496
Here is a screenshot of adding this .vmx parameter using the vSphere Client:
The virtual machine above already has one snapshot and per the configuration change, we should not be able to take any additional snapshots:
Next, we will try to take a second snapshot:
As you can see, an error is thrown that we have reached the maximum number of permitted snapshots. If you would like to disable snapshots all together, you can set the value to be 0 and this will prevent anyone from taking snapshots, including administrators.
Here is a an screenshot of the expanded view of a VM with 496 snapshots:
Note: These snapshots were created with a VM running in an vESXi host and script to exhaust the maximum snapshot depth of 31. Each snapshot level was also exhausted with the maximum number of snapshots. Starting from level-1: it was the maximum depth minus 1, level-2: it was maximum depth minus 2, and so fourth. This was just a test to see what the system could handle, you should not try this a home or on a production VM 😉 Use at your own risk