Every time I go into a Site Recovery Manager engagement and we start talking about how the test functionality works I always get the question of how to make a domain controller available to the test network. I always say I have a script for that, so I thought I’d share it with anyone who might need it.
The script below is pretty simple, it just clones an existing domain controller, changes its network connection to the test network’s portgroup and then boots it up.
#Add PowerCLI Snapin
#Connect to vCenter
connect-viserver <vCenter Name>
new-vm -name <NewVMName> -datastore <DataStoreName> -VM <SourceVM> -ResourcePool <ClusterName>
get-vm <NewVMName> | get-NetworkAdapter | Set-NetworkAdapter -NetworkName <IsolatedPortGroupName> -Confirm:$false
#Sleep for 1 Minute
start-sleep -s 60
#Power on DC
start-vm -VM <NewVMName>
<vCenter Name> is the name of the vCenter to connect to. If having SRM run this script make sure the service account SRM is running under has the required vCenter permissions.
<NewVMName> is the name you want to use for the cloned DC.
<DataStoreName> is the name of the datastore you want to store the clone in.
<SourceVM> is the DC you want to clone.
<ClusterName> is the cluster or resource pool you want to cloned DC to run in.
<IsolatedPortGroupName> is the name of the portgroup you want the cloned DC to use.
And that’s it, after running or having SRM run this short script you’ll have an isolated DC from your DR site connected to your isolated SRM test network. Just be sure and delete this DC when you’re done with your tests.