Thursday 14 November 2013

VMware - Checking on snapshots

The backups failed one night and left a number of snapshots marooned.

(The backup process snapshots the NetApp volume, backups up the VMs, then deletes the snapshots).

To check which machines were affected I created and ran a Powershell script.

First of all I downloaded the VMware PowerCLI from here, you will need an VMware account to download.

Then opened up the PowerCLI to run the following commands:

Set-ExecutionPolicy RemoteSigned

Connect-VIServer vCenterServerName

get-vm | get-snapshot | format-list

This produces quite an in depth list of information, but a little too much as all I'm after is the name of machines with snapshots so I can check them for the backup snapshot. The date and description (as the backup names them as "SMVI Snapshot generated for.......")

Format list will give you the following objects:
Description
Created
Quiesced
PowerState
VM
VMId
Parent
ParentSnapshotId
ParentSnapshot
Children
SizeMB
IsCurrent
IsReplaySupported
ExtensionData
Id
Name
Uid

So my actual query was this which ends with an output option to a text file:

get-vm | get-snapshot | format-list vm,date,description | out-file c:\snapshot.txt

If you want to narrow your search down to a specific container as listed in "VMs and Templates", for example "Citrix" where all your Citrix servers are collected then amend the "get-vm" part of the query:

get-vm -location ”Citrix” | get-snapshot | format-list vm,date,description | out-file c:\snapshot.txt

 







No comments:

Post a Comment