ASR Use powershell to re-protect. Failback from Azure to VMware
I have an ASR appliance in VMware replicating a Vm to Azure. I want to automate failover and failback. I was able to do the test failover and cleanup with powershell.
Start-AzRecoveryServicesAsrTestFailoverJob -ReplicationProtectedItem $ReplicationProtectedItem -Direction PrimaryToRecovery -AzureVMNetworkId $TFONetwork
and
Start-AzRecoveryServicesAsrTestFailoverCleanupJob -ReplicationProtectedItem $ReplicationProtectedItem -Comment "Testing Completed"
This worked! Next, an Unplanned failover
Start-AzRecoveryServicesAsrUnplannedFailoverJob -ReplicationProtectedItem $ReplicationProtectedItem -Direction PrimaryToRecovery -Confirm:$false
and then commit
Start-AzRecoveryServicesAsrCommitFailoverJob -ReplicationProtectedItem $ReplicationProtectedItem
that worked!
I then logged into the new Azure VM, and created a text file on the desktop. Now I want to failback the Azure VM to VMware.
To re-protect I have been trying Update-AzRecoveryServicesAsrProtectionDirection
with no luck.
Update-AzRecoveryServicesAsrProtectionDirection -ReplicationProtectedItem $ReplicationProtectedItem -Direction RecoveryToPrimary -Confirm:$false
This fails with "Object reference not set to an instance of an object." I don't know the difference between using "-Direction RecoveryToPrimary" and "-AzureToVMware". They seem like the same thing.
In the GUI if I start re-protect, I see it asks for 'vCenter Server/vSphere Host' (already filled in with my vCenter), 'Datastore' (already got my vCenter datastore), 'ASR Replication Appliance' (already there) and 'Cache storage account',
If I try Update-AzRecoveryServicesAsrProtectionDirection -AzureToVMware
it then asks me to fill in the parameters, datastore ..i give value shown in GUI ... 'L1DS-SRV02'
processServer .. I assume this is ASR app in my vCenter .. I give value shown in GUI
ProtectionContainerMapping : don't know this one
But it gives me errors like :
Cannot bind parameter 'DataStore'. Cannot convert the "L1DS-SRV02" value of type "System.String" to type
"Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRDataStore".
--
Can anybody help me formulate the powershell commands to do a re-protect and failback to VMware and then get replication back to where it was in the beginning, VMware to Azure?
Also to get the values needed for Update-AzRecoveryServicesAsrProtectionDirection
in the right format .
thanks in advance.