ESXiBackup Folder Cleanup

In an earlier post Directory partition has not been backed up [DC=virtualcenter,DC=vmware,DC=int] I suggested a method to backup the VMwareVCMSDS ADAM database. As Joern posted in a comment, this solution could fill up your D: drive. The following code should help cleanup the ESXiBackup folder and only keep one month worth of history. You can append this to the previous script or schedule it as a separate task.

[cc lang=”powershell”]
$vcenter = “” #This variable may already be defined if you append the previous script.
foreach ($i in Get-ChildItem D:\ESXiBackup\$vcenter)
if ($i.CreationTime -lt ($(Get-Date).AddMonths(-1)))
Remove-Item $i.FullName -recurse -force -confirm:$false -whatif

You’ll want to remove the “-whatif” once you see that the above script is what you want to do 🙂

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

One Response to ESXiBackup Folder Cleanup

  1. Joern says:

    Wonderful Brian !
    Now I do not have to think at all 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *


Notify me of followup comments via e-mail. You can also subscribe without commenting.