Link to home
Start Free TrialLog in
Avatar of patron
patronFlag for India

asked on

Script to list VMs with Snapshot detail on VC like VM name,Date of Snapshot taken and Size of Snapshot

i am looking for script to list VMs with snapshot including date of snap  taken and current size of snap.

Please share if  any best configured script can be used here ?
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland image

checkout VMware Community Pack it includes this script and many more which are very useful.

I would recommend using the following, also VMware recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI

http://powergui.org/index.jspa

and

VMware Community Pack

http://www.virtu-al.net/featured-scripts/vmware-powerpack/
Avatar of patron

ASKER

Thanks a lot for sharing this great info,but here i am looking for command /script to be used which can list vms having snapshot?
This is the one I use. You have to rename it to be a batch file and make the edit for you system.
snapshots.txt
Sorry not a batch file a powershell. rename snapshots.txt to snapshots.ps1
Did you even check the VMware Community Pack, it lists Snapshots!

http://www.virtu-al.net/featured-scripts/vmware-powerpack/

You may want to time to check it, because it also includes many many other Good VMware Tools, specific to VMware Administration, which SHOULD be in your VMware Admin Toolbox!

User generated image
Avatar of patron

ASKER

Thanks,I am ware about this tool,but here i am looking for small command/scipt to be used, so that we can list of vms having snapshot ?

 and powergui -is not allowed for me to use  there in my Prod. environment.
I'm not sure why you cannot use PowerGUI, when you'll need to install  PowerCLI anyway in a Production environment for any script to work.

 The VMware Community Pack will put ticks in your boxes for lots of scripts that you require!
Avatar of patron

ASKER

Got the solution Thanks....
Avatar of patron

ASKER

Actually I tried for..

Get=VM | Get-Snapshot |Format-List |Out-File c:\tmp\snapreport.htm

i am able to see some report here..but this is note complete solution for me...

so would need expert advise if somehow we can fetch report in  format like..


VM Name ,Snapshot Name,Size of Snapshot,Date when taken Snapshot ?

above given solution are fine and i have used as well, but my requirement is ,if someone pls advise report in html/htm format..?
That's easy:
get-vm | Get-Snapshot | select VM, Name, @{n='SizeMB'; e={[math]::round($_.SizeMB,0)}}, Created

Open in new window

Perform export or formatting as required, this gets you the raw data.
Avatar of patron

ASKER

Tried..but no luck,m looking for script ..ll share output in htm/html with a table including  columns like VM name-Date of Snapshot taken,Size of Snapshot ?
Append the following to get a HTML file:
| ConvertTo-Html | Out-File C:\temp\report.csv

Open in new window

Avatar of patron

ASKER

i am able to export output..but missing few data like.. date and size of snapshot ?
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patron

ASKER

Thanks a lot.it is fine now to give data like VM-Snap-Size-Date created.
Avatar of patron

ASKER

great,Thanks