Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-13
17
Medium Priority
?
339 Views
Last Modified: 2015-02-23
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 ?
0
Comment
Question by:patron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 3
  • +1
17 Comments
 
LVL 123
ID: 40497882
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/
0
 
LVL 1

Author Comment

by:patron
ID: 40497895
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?
0
 
LVL 14

Expert Comment

by:RickEpnet
ID: 40497992
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
0
Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

 
LVL 14

Expert Comment

by:RickEpnet
ID: 40497993
Sorry not a batch file a powershell. rename snapshots.txt to snapshots.ps1
0
 
LVL 123
ID: 40498049
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!

SNAPSHOTS SCRIPT!!!!
0
 
LVL 1

Author Comment

by:patron
ID: 40498585
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.
0
 
LVL 123
ID: 40498758
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!
0
 
LVL 1

Author Comment

by:patron
ID: 40499446
Got the solution Thanks....
0
 
LVL 1

Author Comment

by:patron
ID: 40508648
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..?
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40509552
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.
0
 
LVL 1

Author Comment

by:patron
ID: 40521359
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 ?
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40521434
Append the following to get a HTML file:
| ConvertTo-Html | Out-File C:\temp\report.csv

Open in new window

0
 
LVL 1

Author Comment

by:patron
ID: 40563759
i am able to export output..but missing few data like.. date and size of snapshot ?
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 40564177
The HTML export is the same as the output of http:#a40509552, which contains VM name, Snapshot name, the size in MB, and the snapshot creation date. The only issue is that I should have named the output file .HTML, not .CSV . To make sure we are on the same page:
get-vm | Get-Snapshot |
  select VM, Name, @{n='SizeMB'; e={[math]::round($_.SizeMB,0)}}, Created |
  ConvertTo-Html |
  Out-File C:\temp\report.html

Open in new window

0
 
LVL 1

Author Comment

by:patron
ID: 40625400
Thanks a lot.it is fine now to give data like VM-Snap-Size-Date created.
0
 
LVL 1

Author Closing Comment

by:patron
ID: 40625401
great,Thanks
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This Micro Tutorial walks you through using a remote console to access a server and install ESXi 5.1. This example is showing remote access and installation using a Dell server. The hypervisor is the very first component of your virtual infrastructu…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question