Posts Tagged ‘ list

List all of your snapshots (oneliners)

It’s not hard to create a PowerShell script to list your current snapshots, but of course it’s a nice challenge to create a oneliner that’ll take care of this.

I’ve created several oneliners with different output, for instance: this one is to show snapshots of your total VMware infrastructure:

Get-VM | Sort Name | Get-Snapshot | Where { $_.Name.Length -gt 0 } | Select
VM,Name,Description,Created

While in fact in the organisation I work for we have several locations throughout the country and several VMware ESX Servers running on each one which we’ve divided in different Datacenters in our VMware Infrastructure.

So for instance you can also use the following line to list all Snapshots in a specific Datacenter:

Get-Datacenter -Name "Your Datacenter" | Get-VM | Sort Name | Get-Snapshot | 
Where { $_.Name.Length -gt 0 } | Select VM,Name,Description,Created

Or just for one specific cluster:

Get-Cluster "Cluster Name" | Get-VM | Sort Name | Get-Snapshot | Where
{ $_.Name.Length -gt 0 } | Select VM,Name,Description,Created

All of these oneliners give somewhat the same output, which looks like this (company sensitive names are sensored, sorry ;) )

Snapshot listing

You can also add several other cmdlets to change the output of the result data, such as  ConvertTo-HTML or Out-GridView (if you use PowerShell 2.0 already).