PowerShell script to collect VM Snapshot details

Snapshots are the most widely used features in vSphere environment. Ever since this feature was introduced  by VMware it has been popular among customers. But many a times VM level snapshots are mislead with virtual machine backup which creates lot of performance issues and administrators have to spend numerous hours to fix it.

Refer to VMware KB 1015180 for more details on what is Snapshot and how does it works

VMware best practice says although a VM can have maximum of 32 chain-snapshots  but for optimum performance it shouldn’t have more than 2-3 snapshots. Any single snapshot older than 24-72 hours can also cause severe performance issues because snapshot grows along with its associated .vmdk file

However it is equally tricky task for large enterprises to keep track of VM Snapshots and regularly keep deleting older snapshots. There are 3rd party tools available in market but sometimes it conflicts with organizational compliance policies which restricts them to deploy such 3rd party applications in their environment.

So here is a small PowerShell script to solve the purpose which not only gather VM details which has snapshot associated with it but also checks its size, creation date and saves it in .csv format.

Please refer pre-requisites to run this script from my older blog

Connect-VIServer -Server server_fqdn -User username -Password passwd
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction 'SilentlyContinue'
Clear-Host
$e = Get-VM | Get-Snapshot
$f = $e | Select-object vm,VMId,name,Description,SizeGB,created
$f | Export-Csv -Path "C:\path_name\snapshot.csv"

With this I end this blog… I hope it helps… till then Happy Reading… 🙂

4 thoughts on “PowerShell script to collect VM Snapshot details

Add yours

  1. If I want to what products are installed in VM snapshots, so I can revert the required one, what script I need to run?

    Like we have multiple snap shots on multiple VM servers. And some time we need a snapshot with specific product installed. The desc of file may dont have such information everytime. So without reverting the snapshot, can we know the installed products list on VM snapshot?

    Thanks in advance
    Yogesh

    Like

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑