Quantcast
Channel: VMware Communities : Discussion List - Site Recovery Manager
Viewing all articles
Browse latest Browse all 3691

SRM API Help

$
0
0

SRM 6/vCenter 6 - 2 sites - Netapp SRA

 

I need to write a script that automatically generates a list of VMs that are actively being failed over in the current protection group/recovery plan that is being run.  The script below works when connecting to the protected-site SRM server but it does not work when connecting to the recovery site SRM server (for instance, when a true disaster occurs and the protected site is down.  I'm using the Meadowcroft SRM commandlets out there for ease but the script acts the same if I query the API directly.

 

 

###########################################

$SrmConnection = Connect-SrmServer $RecoverySiteSRM -credential $SRMCreds -WarningAction SilentlyContinue

$ProtectedVMs=Get-SrmRecoveryPlan -Name $recoveryplan | Get-SrmProtectionGroup | Get-SRMProtectedVM

$protectedVMs | % {$_.Vm.UpdateViewData() }  #--> This is where it errors if I'm connected to the recovery site rather than the protected site.  Error is: Exception calling "UpdateViewData" with "0" argument(s): "The object has already been deleted or has not been completely created"

$SRMVMs = @()

$protectedVms | %{

        $output = "" | select VmName

        $output.VmName = $_.Vm.Name

        $SRMVMs += $output

    }

 

##############################################

 

I get this back for each VM as expected.  But I need to convert this to a real VM name.  This works if connected to the main SRM server but not if connected to the recovery site srm server.

Vm                 : VMware.Vim.VirtualMachine

ProtectedVm        : protected-vm-2259

PeerProtectedVm    : protected-vm-2324

State              : Recovered

PeerState          : FailedOver

NeedsConfiguration : False

Faults             :

 

Any way around this or is there a better way to get the list of protected VM names when you only know the Recovery plan name during an SRM failover and you only have access to the recovery site SRM server?

 

Reference post: PowerCli SRM ListAssociatedVms throwing The Operation is not support on this Object


Viewing all articles
Browse latest Browse all 3691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>