PowerShell – Failed Host

I had the opportunity to break out a little powershell today to go grepping for some vi-events. I thought others might get a benefit out of this so here is a little code snippet for you to enjoy.

Our environment is made up of several clusters with multiple hosts in each. One of our hosts happened to die the other day and we wanted to know who was affected to send out an outage report. If you look in the events log, you’ll see a message along the lines of “Virtual Machine was restarted on since failed” Informative and pretty easy to search for. Here’s my code:

get-cluster -name |get-vm |get-vievent | % {$_fullformattedmessage | select-string " failed"}

And that’s it. This will search through all the events and find all the entires that you were looking for. Happy hunting.

Matt Patterson avatar
About Matt Patterson
Husband, Father of 3, Programmer at heart, spends his days running ridiculously large data centers in the midwest.