O R G A N I C / F E R T I L I Z E R: show vmware snapshots script

Aug 12, 2008

show vmware snapshots script

here’s a simple, little powershell script to show all of your snapshots.  you have to use the vmware vi toolkit and virtual center to do this.  i have mine going to a html file, in this example.

# =============================================================================
# NAME: VMSnapshots
# AUTHOR: Marcus C. Oh, Cox Communications, Inc.
# DATE  : 8/5/2008
# COMMENT: A real simple script to pull back snapshots of a VM.
# =============================================================================

$myVC = $Args[0]

If ($Args[0] -eq $null) {
    Write-Warning "Please provide a server name as an argument."
} else {
    $VCServer = Connect-VIserver -server $myVC -credential (Get-Credential $_.username)
    Get-VM -Server $VCServer | Get-Snapshot `
        | ConvertTo-Html -Property created,quiesced,powerstate,`
        @{label = "Note";expression = {If ($_.Description -ne ''){$_.Description}else{"None"}}},vm `
        -Title "VM Snapshots Report" > c:\temp\VMSnapshot.html