List All VM’s with snapshots – “One-liner Wednesdays”

snapshot_find
Here is a quick way to list all of your virtual machines’ snapshots that are managed through the vCenter you are currently connected to.

get-vm | get-snapshot | select vm,powerstate | Out-GridView

snapshots_1liner01
I like using the “Out-GridView” cmdlet because it allows you to quickly filter the list. This is excellent when you want to sort specific types of vm’s. Example: “app”, “db”, “web” etc.


Reference:
VMware PowerCLI Documentation
Microsoft PowerShell Documentation

List HA reboots within the past 5 days – PowerCLI

    On 4.1

$Date = Get-Date
$HAVMrestartold =5
Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type info | Where {$_.FullFormattedMessage -match "was restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending

    On 5.x

$Date = Get-Date
$HAVMrestartold =5
Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending