Find old snapshots (modification of post by view diff)
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1548"></script>download | new post
Simple PowerCLI example to find old snapshots. Note that I would not actually use the techniques shown here, this script was intentionally written this way as a part of a training video in which I am building on techniques.
- param ( $Age = 30 )
- Connect-VIServer vcenter.domain.com
- $vm = Get-VM
- $snapshots = Get-Snapshot -VM $vm
- Write-Host -ForegroundColor Red "Old snapshots found:"
- foreach ( $snap in $snapshots ) {
- if ( $snap.Created -lt (Get-Date).AddDays( -$Age ) ) {
- Write-Host "Name: " $snap.Name " Size: " $snap.SizeMB " Created: " $snap.Created
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository