You can protect a virtual machine by replicating it to a remote SRM site.
Procedure
- Connect to the vCenter Server system that the SRM server is registered with.
Connect-VIServer -Server vc3.example.com -User 'MyAdministratorUser' -Password 'MyPassword'
- Establish a connection to the local SRM server by providing credentials to the remote SRM site.
$srmConnection = Connect-SrmServer -RemoteUser 'MyRemoteUser' -RemotePassword 'MyRemotePassword'
- List all protection groups associated with the SRM server.
$srmApi = $srmConnection.ExtensionData $protectionGroups = $srmApi.Protection.ListProtectionGroups()
- Associate the TestVM virtual machine with the ProtGroup1 protection group and enable the protection for that virtual machine.
$vmToAdd = Get-VM "TestVM" $targetProtectionGroup = $protectionGroups | where {$_.GetInfo().Name -eq "ProtGroup1" } $targetProtectionGroup.AssociateVms(@($vmToAdd.ExtensionData.MoRef)) # Enable protection for that virtual machine $protectionSpec = New-Object VMware.VimAutomation.Srm.Views.SrmProtectionGroupVmProtectionSpec $protectionSpec.Vm = $vmToAdd.ExtensionData.MoRef $protectTask = $targetProtectionGroup.ProtectVms($protectionSpec) while(-not $protectTask.IsComplete()) { sleep -Seconds 1 }