#This is a script to failover multiple groups of virtual machines.
This is for a Virtual Infrastructure based in two datacenters. Each datacenter has a SAN with a series of LUNs that are mirrored (SRDF)to the other location.
There is one VirtualCenter that is a VM that this script can be run against. There is a seperate procedure to failover the VirtualCenter VM.
This carries out the following actions on each virtual machine in the folders specified:
Attempt to shutdown the OS
Perform a Power Off of the VM
Pause to allow other procedures to be run to failover the storage and VLANs
Get the Hosts to Rescan for VMFS partitions
Remove the VM from the Inventory
Add the VM to the Inventory but against an ESX host in the target datacenter.
Perform a Power On of the VM
Usage: & .\VMFailover.ps1 Mode Datacenter Folder1 etc..
Where:
Mode is either DEMO or LIVE - (LIVE is the only mode that will execute commands).")
Datacenter is target for the virtual machines to failover to (either "$dc1" or "$dc2").
Folder1 (Folder2, etc) are the VirtualCenter folders containing the VMs being moved.
This script assumes you have already connected to VirtualCenter with Get-VIServer
It also assumes that the user has full administrator rights to the Datacenter.