vMotion all guests except one

If you have larger ESXi servers and you need to vMotion all guests except one (MSCS server, exchange CCR or something that you don't want to vMotion until a later time).  Right click and migrate is a long and tedious process and can potentially be error filled.

Powershell allows fantastic functionality for something like this.  Note the words encased in <> are variables you need to change.

Connect-viserver <VC>

get-vmhost <VC> | get-vm | where {$_.Name -notmatch "<Guest to Exclude>"} | move-vm -destination (get-vmhost <ESX Server to move to>)

That's it! 

Error's may occur and they are displayed in Red at the powershell command prompt but the nice thing is that even though it may error on one guest it still continues through the rest of them.

Comments