Snapshot Management with Power CLI

Command to list the  properties of snapshot  using  power cli

get-vm | get-snapshot | format-list

Description
Created
Quiesced
PowerState
VM
VMId
Parent
ParentSnapshotId
ParentSnapshot
Children
SizeMB
IsCurrent
IsReplaySupported
ExtensionData
Id
Name
Uid

Generate complete snapshot inventory with few details

       get-vm | Get-Snapshot

Export complete snapshot inventory to csv file

get-vm | get-snapshot | format-list | Export-Csv C:\snaps.csv

Generate snapshot information inside folder  

   get-vm -location “VMWARE-Administration” | get-snapshot

Generate snapshot information with specific Description

get-vm | get-snapshot  | where {$_.Description -match “Avamar Snapshot generated for back” }    ->

Generate snapshot information with specific Description and formatted mode

get-vm | get-snapshot  | where {$_.Description -match “Avamar Snapshot generated for back”}| Format-Table -Property VM,Name,Created,Description, SizeMB


Create new snapshot with description and name

get-vm TEST-VM-01 |New-Snapshot -name snspshottest -Description  snapshottest

Get snapshot information about specific VM      

get-vm TEST-VM-01 | Get-Snapshot

Remove snapshot of a specific VM

get-vm TEST-VM-01 |Get-Snapshot |Remove-Snapshot    ( It will ask to confirm to perform snapshot removal )

get-vm TEST-VM-01 |Get-Snapshot |Remove-Snapshot  -Confirm:$false


Remove Snapshot By Description

get-vm | get-snapshot  | where {$_.Description -match “Avamar Snapshot generated for back”}| Remove-Snapshot -Confirm:$false -RunAsync

List snapshot created prior to “X” days

Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-130)}
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-60)}

Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-60)} | Select-Object VM, Name, Created, SizeMB

Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(1)} | Select-Object VM, Name, Created, SizeMB