Update (December 2026): VMware Site Recovery Manager (SRM) has since been renamed VMware Live Site Recovery, and in VMware Cloud Foundation 9.1 it is delivered as VCF Protection and Recovery, a single appliance that replaces the separate SRM and vSphere Replication appliances (Broadcom KB 444864). SRM has been appliance-only since 8.5, so Windows paths such as C:\Program Files no longer apply. The concepts in this post (site pairs, array managers, SRAs, protection groups and recovery plans) are unchanged; the name SRM is kept below for readability. The first version of this script used Get-SRRecoveryPlan and Get-SRProtectionGroup, which are not PowerCLI cmdlets; it now uses Connect-SrmServer and the SRM API that ships with PowerCLI. For SRM 8.7 and later you can also use the VMware.Sdk.Srm module.

To validate any failures on VMware Site Recovery Manager (SRM), you can use PowerShell along with VMware PowerCLI to check the status of the recovery plans, protection groups, and the overall SRM environment. Here’s a PowerShell script that helps you validate SRM failures:

Validating SRM with the SRM APIConnect-VIServerboth vCenter ServersConnect-SrmServerSRM API, local +remote loginList recoveryplansRecovery.ListPlans(): state per planList protectiongroupsProtection.ListProtectionGroups(): stateand VMsReportflag anything notReady
Connect-SrmServer exposes the SRM API objects; the newer VMware.Sdk.Srm module (Connect-SrmSdkServer) offers the same checks through the REST API.
# PowerCLI (VCF.PowerCLI or VMware.PowerCLI) includes Connect-SrmServer for the SRM API
$protectedSiteServer = '<PROTECTED_SITE_VCENTER_FQDN>'
$recoverySiteServer  = '<RECOVERY_SITE_VCENTER_FQDN>'

$protectedSiteCredential = Get-Credential -Message 'Credentials for the protected site vCenter Server'
$recoverySiteCredential  = Get-Credential -Message 'Credentials for the recovery site vCenter Server'

Connect-VIServer -Server $protectedSiteServer -Credential $protectedSiteCredential -ErrorAction Stop | Out-Null
Connect-VIServer -Server $recoverySiteServer  -Credential $recoverySiteCredential  -ErrorAction Stop | Out-Null

# Log in to the SRM server paired with the protected site vCenter (and to the remote site)
$srm = Connect-SrmServer -Server $protectedSiteServer -Credential $protectedSiteCredential `
          -RemoteCredential $recoverySiteCredential -ErrorAction Stop
$srmApi = $srm.ExtensionData

# Function to Check Recovery Plan Status
function Get-RecoveryPlanStatus {
    param ([Parameter(Mandatory = $true)] $RecoveryPlan)
    $info = $RecoveryPlan.GetInfo()
    [PSCustomObject]@{
        Type   = 'RecoveryPlan'
        Name   = $info.Name
        State  = $info.State          # e.g. Ready, Running, NeedsCleanup, NeedsReprotect, Incomplete
        Issue  = $info.State -notin 'Ready', 'Protecting'
    }
}

# Function to Check Protection Group Status
function Get-ProtectionGroupStatus {
    param ([Parameter(Mandatory = $true)] $ProtectionGroup)
    $info  = $ProtectionGroup.GetInfo()
    $state = $ProtectionGroup.GetProtectionState()
    $vms   = $ProtectionGroup.ListProtectedVms()
    $bad   = @($vms | Where-Object { $_.NeedsConfiguration -or $_.State -ne 'Ready' })
    [PSCustomObject]@{
        Type   = 'ProtectionGroup'
        Name   = $info.Name
        State  = "$state, $(@($vms).Count) VMs, $($bad.Count) need attention"
        Issue  = $bad.Count -gt 0
    }
}

# Main Script
$results  = foreach ($plan in $srmApi.Recovery.ListPlans())             { Get-RecoveryPlanStatus  -RecoveryPlan $plan }
$results += foreach ($pg   in $srmApi.Protection.ListProtectionGroups()) { Get-ProtectionGroupStatus -ProtectionGroup $pg }

$results | Format-Table Type, Name, State, Issue -AutoSize
if ($results | Where-Object Issue) { Write-Warning 'SRM objects need attention - see the table above.' }

# Disconnect
Disconnect-SrmServer -Server $srm -Confirm:$false
Disconnect-VIServer -Server $protectedSiteServer, $recoverySiteServer -Confirm:$false

Save the above script in a .ps1 file and run it with PowerShell. The script will prompt you to enter the credentials for the protected site and recovery site vCenter Servers. It will then connect to both vCenter Servers and to SRM, retrieve the state of all recovery plans and protection groups, and display the results in the PowerShell console.

The script will check the state of each recovery plan (for example Ready, NeedsCleanup after a test, or NeedsReprotect after a failover) and, for each protection group, its protection state and any protected VMs that need configuration. Anything that is not ready is flagged in the Issue column. Replace the values in <ANGLE_BRACKETS> with your own.

This script helps you quickly validate failures in your SRM environment and can be scheduled to run periodically for proactive monitoring. You can also integrate it into your monitoring systems to receive alerts in case of any issues with SRM recovery plans and protection groups. For related procedures see performing a test failover with SRM.

Leave a Reply