As a VMware vSphere administrator, one of the important things that you should check for on a regular base is active snapshots on your virtual machines.

Keeping snapshots for a long time can affect virtual machine performance negatively. Furthermore, your datastore could completely fill up because of rapidly growing active snapshots, resulting in virtual machines being paused.

Checking for active snapshots using the vSphere web client or Infrastructure client isn’t very handy. There’s no view in the graphical interface to quickly display all active snaphots for all virtual machines. The best tool for the job is PowerCli.

I use the following one-liner to check for active snapshots:

Get-VM | Get-Snapshot | Format-Table VM,Name,SizeGB,Created -AutoSize

When connected to VMware Virtual Center, this command will check all Virtual Machines for active snapshots, and formats the output listing the virtual machine name, the name of the snapshot, the optional description of the snapshot, the size of the snapshot in GB and finally the date the snapshot was created. At the end, the output is aligned using the AutoSize command.

Below is an example of how this would look.

PowerCli_Get-Snapshot_Example

 

Optionally, you could omit the Description part in the formatting process to make sure the output fits in your console screen.

As this is a command I want to run on a daily base, I don’t want to type this command every time, as I’m lazy 🙂

Therefore, I can add it as a function to my PowerShell profile.

function Get-SnapShotOverview {
Get-VM | Get-SnapShot | Format-Table VM,Name,Created,SizeGB -AutoSize
}

You have to give your function a name, and I’ve chosen Get-SnapShotOverview as a name.

From now on, I only have to type Get-SnapshotOverview to list all active snapshots and format the output as I like it. (remember: you can use tab completion)

To learn more about Windows PowerShell profiles, you can use the excellent built-in help page from within PowerShell:

help about_profile

 

Leave a Reply

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