Skip to main content

Hi,

We are looking at improving/automating our VM decommission process.

At present, we have a dedicated VSA backup and Storage Policy that writes direct to tape media with 7 years retention on the backup copy.  


This backup subclient runs on the weekend and targets a dedicated vCenter Resource Pool that is only for VMs scheduled to be decommissioned. 

As part of the decommission process, admins will move any VM that is to be retired into the Resource Pool and power it off ahead of the weekend backup to tape.

We are now wondering if it is possible to also have this same backup job then delete the backed-up VM(s) from the vCenter/datastore so that an admin doesn’t have to manually do this the following Monday?

Obviously, robustness and safety are paramount here, but just curious if anyone has achieved this and if so, how?

Regards,

Michael​​​​​​

Hi @michaelf 

 

I haven’t personally seen this in my years working with/for Commvault, but I expected that this could be possible with the use of a post script.

Ref: Pre-processes and Post-processes - Advanced (commvault.com)

 

If you have PowerCLI installed on the VSA used for the job, you could leverage this to identify and delete the VM’s.

Examples of some of the cmdlet’s you could use are: 
Get-ResourcePool -Name "ResourcePoolName" | Get-VM
Get-ResourcePool Ref: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/f2319b2a-6378-4635-a1cd-90b14949b62a/0ac4f829-f79b-40a6-ac10-d22ec76937ec/doc/Get-ResourcePool.html

Get-VM Ref: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/85a74cac-7b7b-45b0-b850-00ca08d1f238/ae65ebd9-158b-4f31-aa9c-4bbdc724cc38/doc/Get-VM.html

 

Remove-VM -VM 'myVM' -DeletePermanently
Remove-VM Ref: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/85a74cac-7b7b-45b0-b850-00ca08d1f238/ae65ebd9-158b-4f31-aa9c-4bbdc724cc38/doc/Remove-VM.html

 

As a very basic example, It might start something like this:

#Connect to vCenter:
Connect-VIServer –Server “vCenterName”

#Identify VM’s in ResourcePool and list those in a file:
Get-ResourcePool -Name "ResourcePoolName" | Get-VM | Out-String | Format-list | Out-File C:\Temp\DeleteVMList.txt

#Delete VM’s in the file list:
Get-Content C:\Temp\DeleteVMList.txt | foreach { Remove-VM $_ -DeletePermanently -Confirm:$false }  | Out-File C:\Temp\DeletedVMs.log

 

Obviously you’d need to amend this to suit your environment and also test this outside of production to evaluate if this meets requirements.

 

Hope this could be of some use to you, keep us updated with how you get on here.

 

Best Regards,

Michael


Reply