Please enable Javascript for better experience...
Snapshot deletion automation
By Jitendra | Oct 19, 2022 | In Articles | Update: Oct 19, 2022 | Total Views [ 390 ]
(0 Like)
Rate

intial description

Sanpshot deletion automation

Pre-reuisites are as below:

1. Powercli must be installed on the server from where you will run this script.

2. Vcenter must be accessible from there.

3. You need to export your credentials in xml using export-clixml powershell command.

Sanpshot older thann 60 days deletion.

Save the below code with .ps1 extension.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

import-module vmware.vimautomation.core
$cred=Import-Clixml -Path 'C:\jitendra.xml'
Connect-VIServer vmwarediary_vcsa -Credential $cred
$vmNames = Get-Content -Path C:\servers.txt
Get-VM -Name $vmNames | get-snapshot | Where-Object {$_.Created -lt (Get-Date).AddDays(-60)} | Remove-Snapshot -confirm:$false -verbose

------------------------------------------------------------------------------------------------------------------------------------------------------------------

If you have any query, please send us an email on jitendra.k.singh.october13@gmail.com.  I will try to reply as soon as possible.

Please take benefit of this script and try to let others to take the same benefit.

Share this

About the Author

Jitendra
Jitendra
Contributer VMwareDiary.com

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment