sivagndl
Enthusiast
Enthusiast

SRM recovery plans VMs report

Jump to solution

I am unable to pull the SRm recovery plan vms FinalPowerState . Thanks for advance..

Using below code form https://github.com/benmeadowcroft/SRM-Cmdlets/blob/master/Examples/ReportConfiguration.ps1

SRM-Cmdlets/ReportConfiguration.ps1 at master · benmeadowcroft/SRM-Cmdlets · GitHub

Get-SrmProtectionGroup PGname | %{

       $pg = $_

        $pginfo = $pg.GetInfo()

        $pvms = Get-SrmProtectedVM -ProtectionGroup $pg

        $rps = Get-SrmRecoveryPlan -ProtectionGroup $pg

        $rpnames = $rps | %{ $_.GetInfo().Name }

        $pvms | %{

            $pvm = $_

            if ($srmMajorVersion -ge 6 -or ($srmMajorVersion -eq 5 -and $srmMinorVersion -eq 8))

             {

                $rs = $rps | Select -First 1 | %{ $_.GetRecoverySettings($pvms.Vm.MoRef) }

            }

            $output = "" | select group, name, moRef, needsConfiguration, state, plans, priority, finalPowerState, preCallouts, postCallouts

            $output.group = $pginfo.Name

            $output.name = $pvm.Vm.Name

            $output.moRef = $pvm.Vm.MoRef # this is necessary in case we can't retrieve the name when VC is unavailable

            $output.needsConfiguration = $pvm.NeedsConfiguration

            $output.state = $pvm.State

            $output.plans = [string]::Join(",`r`n", $rpnames)

            if ($rs) {

                $output.priority = $rs.RecoveryPriority

                $output.finalPowerState = $rs.FinalPowerState

                $output.preCallouts = $rs.PrePowerOnCallouts.Count

                $output.postCallouts = $rs.PostPowerOnCallouts.Count

            }

            $output

        }

    }

pastedImage_1.png

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Are you sure $rs gets a value?

Perhaps adds an else-block where you show that for a protectiongroup there was no $rs.

This looks like the issue reported in SRM 8.1 PowerCli and API code

But no solution mentioned I'm afraid


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Are you sure $rs gets a value?

Perhaps adds an else-block where you show that for a protectiongroup there was no $rs.

This looks like the issue reported in SRM 8.1 PowerCli and API code

But no solution mentioned I'm afraid


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
sivagndl
Enthusiast
Enthusiast

Thanks Lucd. its working..

0 Kudos