PowerShell Show VM having snapshots

By default a param minus 30 days. Save it to a *.ps1 file and it ready to use.

param ($Age = 30)

Connect-VIServer localhost
$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 “MachineName:” $snap.VM “Name: ” $snap.Name ” Size: ” $snap.SizeMB ” Created: ” $snap.Created

This entry was posted in Esx4, PowerShell, VMWare and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *