PowerCLI Script – Report Virtual Machines with 3 days older VM Snapshots

This could be one among the very few PowerCLI scripts in my blog. I am in learning phase to create a PowerCLI script to automate and get the report of virtual infrastructure within short span of time. This script also created with the help of one of my friend. In this post, I am going to discuss about the PowerCLI script which helps us to report the Virtual Machines with 3 days older VM snapshots and export the output in Excel (.CSV) file. It is always recommended not to keep VM snapshots more than 24- 72 hours. The VM snapshot file continues to grow in size when it is retained for a longer period. This can cause the snapshot storage location to run out of space and impact the system performance. This PowerCLI script could be really useful to identify the Virtual machines with 3 days older snapshot and delete them immediately or raise a concern to the respective team for the snapshot deletion before VM snapshots causes outage to your production infrastructure.

PowerCLI Script – Report Virtual Machines with 3 days older VM Snapshots

How to Execute the Script?

Copy and Paste the above Script and save it in the Notepad. Name the script as VMSnapShot3DaysOld.ps1

  1. Execute the Script in PowerCLI “.\VMSnapShot3DaysOld.ps1″
  2. Input  vCenter Server Name to execute the script to get the report of VM Snapshots older then 3 days
  3. Enter the Username with administrative credentials on vCenter Server
  4. Enter the password for the above entered Username
  5. Hit Enter to execute the script and pull the report.

VM Snapshots older than 3 days

Script Output

Virtual Machines with 3 days older VM Snapshots will be exported and saved in the Microsoft Excel output file with the filename “VMSnapshot3DaysOld_Today_Day.CSV”  under the same directory where the PowerCLI Script “VMSnapshot3Daysold.PS1”  is located.
vm-snapshots-older-than-3-days-1

When you open the output Excel (.CSV) file “VMSnapshot3DaysOld_Today_Day.CSV”, You will be able to get the details of Virtual Machine which has 3 days older VM Snapshots.  This output file contains Virtual Machine Name, Snapshot Name and Date Created.

vm-snapshots-older-than-3-days-2

That’s it. We are done with the PowerCLI script and got the awesome output with the list of Virtual machines which contains 3 Days older VM Snapshot. I hope this script will be informative for you.  Thanks for Reading!!!. Be social and share it in social media, if you feel worth sharing it.

VM Snapshot Related Posts:

VM Snapshot – How to Change default VMware Snapshot location in ESXi 6