@daniel.martinez-42326 The recommended way is to do it directly via Prism Central wherein you will get an option to select multiple VMs and then perform the delete action on it.
For REST API based deletion, we have a rest API to delete a single VM using the VM UUID. So, you will need to create a script to first get the VM UUIDs (using the VM GET API call) in case if you don’t have it already and then use the VM UUIDs to delete the VMs using the VM DELETE REST API call.
Other way to do it could be via the following process:
- Write a list of VM names that you want to delete into a file (each name in new line). For example File name could be - '/tmp/vms_to_delete'
- Run the following command from any CVM in the cluster (login as nutanix user) to delete the VMs listed in step 1 (change the filename based on the name provided in step 1):
for i in $(cat /tmp/vms_to_delete); do echo $i && acli vm.delete $i; done
-- It will ask you to type yes to confirm each of them, so it is quite safe
@Nupur.Sakhalkar do we have an option, where it will not even ask for confirmation before deleting each vm?
@pkjarora You can use this command instead to forcefully say yes for deleting each VM listed in the /tmp/vms_to_delete file instead of it asking for confirmation on deleting each VM:
for i in $(cat /tmp/vms_to_delete); do echo $i && (echo yes | acli vm.delete $i); done