Is there a way to call these methods to unprotect and unassociate a particular VM from a protection group?
I was looking at one of the old blogs about it in PowerCLI 5.5 R2 and the Site Recovery Manager API - VMware vSphere Blog and wasn't able to construct a way to unprotect VM from a group, although I was just able to get all the VMs with their protection groups associated with.
$SrmConnection=Connect-SrmServer
$SrmApi = $SrmConnection.ExtensionData
$ProtectionGroups = $SrmApi.Protection.ListProtectionGroups()
foreach($PG in $ProtectionGroups) {
$PG.ListProtectedVMs() | Select @{N='ProtectionGroup';E={($PG.GetInfo().Name)}},VmName,State,PeerState
}
Using the protectiongroup you have in $pg, can't you do.
$pg.UnprotectVms($vm.ExtensionData.MoRef)
Or if you want to unprotected all VMs in a group
ForEach-Object -Process {
$pg.UnprotectVms($_.vm.MoRef)
}
Or alternatively
$pg.UnprotectVms($protVM.vm.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Using the protectiongroup you have in $pg, can't you do.
$pg.UnprotectVms($vm.ExtensionData.MoRef)
Or if you want to unprotected all VMs in a group
ForEach-Object -Process {
$pg.UnprotectVms($_.vm.MoRef)
}
Or alternatively
$pg.UnprotectVms($protVM.vm.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Even though $PG and $vm do have values, calling the method $pg.UnprotectVms($vm.ExtensionData.MoRef) doesn't work.
Sorry, I used a wrong value. Instead of using "get-vm TESTVM21" for $vm, I used the value of "$ProtectionGroups[3].ListProtectedVms()"
It works.