Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, July 9, 2014

VMware: Prepare list of VMs with snapshots using PowerShell

VMware snapshots plays important role for VM backup. It is recommended to remove old snapshots as they consume space and may create problems if somebody revert the VM with old snapshot. If you have handsome amount of Virtual Machines, then it will be difficult and time consuming for you to manage those snapshots manually. 

In this article, we will be generating a report of VMs, having snapshots. To prepare that report we'll be using vSphere PowerCLI to connect with vCenter center and then use "Get-VM" and "Get-Snapshot" cmdlets. 

Note: To perform below operations, you will need to install VMware vSphere PowerCLI on your machine.
1. Open vSphere PowerCLI.

2. Connect to vCenter Server.




3. Prepare list of VMs having snapshot.
   Get-VM | Get-Snapshot | format-list

Format-List will provide below properties:
  • Description
  • Created
  • Quiesced
  • PowerState
  • VM
  • VMId
  • Parent
  • ParentSnapshotId
  • ParentSnapshot
  • Children
  • SizeMB
  • IsCurrent
  • IsReplaySupported
  • ExtensionData
  • Id
  • Name
  • Uid

Here we have all the properties of a snapshot. Now we can format our report to display required infomation.
   Get-VM | Get-Snapshot | format-list VM, Created, SizeMB
If you want to redirect the output into any text file then it can be redirected like this:
   Get-VM | Get-Snapshot | format-list | out-file d:\snapshot_report.txt
Hope this article provided you a quick and easy way to list the snapshot reports for your enviroment. :)

1 comment:

  1. I would like to read something more on this topic or related topics.

    ReplyDelete