PowerShell, Hyper-V, SCVMM: Bulk repair VM's

Before you continue please consider clicking on one of the horrible ads. I know they are a pain but they help me pay for the hosting of this site. It owes me a lot of money. Sob story over.

VM's can show as failed in SCVMM for a multitude of tedious and annoying reasons. It's one of the many reasons why I really don't like it, and when a VM is showing as failed you better belief SCVMM isn't going to migrate it or power it on or any of the "useful" things that you need it for.

This is a quick script to repair all VM's in your cluster that are showing as failed due to a migration issue.

$fixvm = Get-SCVirtualMachine | Where-Object -FilterScript {$_.status -like "MigrationFailed"} 

foreach ($fixv in $fixvm)
    {
    Repair-SCVirtualMachine -vm  $fixv -Dismiss 
    }