VMware Solutions Discussions

Script to register vm's on a snapmirror

gary_thomas
2,288 Views

Morning,

I was hoping someone could advise of a script or a util to register all the VM's into a ESX environment after snapmirror is broken to a DR site just to automate a timesink process.

Be nice if it had some sort of GUI that you could select just the ones you want, but anything would do nicely atm.

I expect this is a fairly common thing, so hopefully there is a fair bit of material around already instead of having to write my own.

Cheers

1 REPLY 1

erick_moore
2,288 Views

I  have a few things over at my site: theselights.com .   The ESX to vSphere migration posts should have what you need.  Here is the VM registration piece:


#----{ Register VMs that were chosen to be migrated

Write-Host "Registering VMs to: " $newVC
Foreach ($vm in $vmsToMigrate) {

dir $storePath | where {$_.PSChildName -like "*$vm*"} | % { New-VM -vmhost $vSphereHost -VMFilePath $_.DatastoreFullPath } | Out-Null

}

The variables get set earlier in the script so I would recommend checking the full thing out.  There are other scripts on there that will break your SnapMirror, find all VMs on a datastore, etc.

Thanks,

Erick

Public