<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: VMware SDK for SRM - PlanId Query in Site Recovery Manager Discussions</title>
    <link>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987202#M14288</link>
    <description>&lt;P&gt;I ran into a similar issue. Anyone within this community have any advice or insight?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2023 01:37:16 GMT</pubDate>
    <dc:creator>Nano_JT</dc:creator>
    <dc:date>2023-09-19T01:37:16Z</dc:date>
    <item>
      <title>VMware SDK for SRM - PlanId Query</title>
      <link>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987195#M14287</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear VMware community&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am currently exploring the VMware.Sdk.srm module to interact with the SRM REST API for a project involving disaster recovery and business continuity. While navigating this process, I have encountered a question regarding the retrieval of the 'PlanId' value and the overall usage of this parameter in my scripting efforts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To provide context, I have outlined the steps I have taken so far:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. I initiate my script by obtaining the pairing ID with the command:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```powershell&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$pairings = Invoke-SrmGetPairings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Following this, I compile a list of recovery plans associated with the obtained pairing ID:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```powershell&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$plans = Invoke-SrmGetAllRecoveryPlans -pairingId $pairings.List.pairingid.guid&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. From the list of recovery plans, I extract relevant information from a plan named 'PlanName1' using the following line of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```powershell&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$planid = $plans.list | Where-Object { $_.Name -eq "PlanName1" }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4. My intention is to use the 'PlanId' I've gathered in the previous step to retrieve recovery steps for this particular plan. However, when executing the following command, I encounter an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```powershell&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invoke-SrmGetRecoverySteps -PairingId $pairings.List.pairingid.guid -PlanId $planid.Id -ViewMode test&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The error looks like this: Invoke-SrmGetRecoverySteps: Error converting value {null} to type 'System.Int64'. Path 'list[0].start_time', line 1, position 213.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To clarify my query further, when I inspect the `$planid` variable, it provides the following details:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;```powershell&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Status : READYSTATE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Id : DrRecoveryRecoveryPlan:9fzzzzz-23zz-48zz-b2zz-bzzzzzzzzzz:4zzzzzzzz-7zzz-4zzz-9fzz-b7zzzzzzzzz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProtectedSiteName : vcenter1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RecoverySiteName : vcenter2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProtectedVcGuid : 80zzzzz-95zz-4zzz-9zzzz-f4zzzzzzzz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RecoveryVcGuid : 89zzzzz-69zz-4bzz-97zz-5zzzzzzzz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Name : RecoveryPlan1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Description :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Location : DrFolder:DrRecoveryRootFolder:442zzzzz-77zz-46zz-9fzz-bzzzzzzzz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LocationName : Recovery Plans&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Progress : 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IsRunning : False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In summary, I would greatly appreciate your assistance in clarifying whether the 'Id' property within the `$planid` variable contains the 'PlanId' I should be using in the `Invoke-SrmGetRecoverySteps` command.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 20:53:59 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987195#M14287</guid>
      <dc:creator>jaychinut</dc:creator>
      <dc:date>2023-09-18T20:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: VMware SDK for SRM - PlanId Query</title>
      <link>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987202#M14288</link>
      <description>&lt;P&gt;I ran into a similar issue. Anyone within this community have any advice or insight?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 01:37:16 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987202#M14288</guid>
      <dc:creator>Nano_JT</dc:creator>
      <dc:date>2023-09-19T01:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: VMware SDK for SRM - PlanId Query</title>
      <link>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987274#M14289</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;The Id is the correct field you should use when need to call object-related APIs (like recovery plans, protection groups, etc).&lt;/P&gt;&lt;P&gt;Here I suspect there is some issue with the PowerCLI cmdlets and the REST API itself.&lt;BR /&gt;Until the problem is fixed, you can use PowerShell to communicate with this exact API endpoint. Here is a snippet:&lt;/P&gt;&lt;P&gt;// Authenticate to the local site&lt;/P&gt;&lt;P&gt;$srmConnection =&amp;nbsp;Connect-SrmSdkServer -Server $srmLocalHostName `&lt;BR /&gt;&amp;nbsp;-User $localVcUsername `&lt;BR /&gt;&amp;nbsp;-Password $localVcPassword `&lt;BR /&gt;&amp;nbsp;-RemoteUser $remoteVcUsername `&lt;BR /&gt;&amp;nbsp;-RemotePassword $remoteVcPassword&lt;/P&gt;&lt;P&gt;$pairings = Invoke-SrmGetPairings&lt;/P&gt;&lt;P&gt;$pairingId = $srmConnection.ConnectedPairing.PairingId&lt;/P&gt;&lt;P&gt;// Find the desired plan&lt;/P&gt;&lt;P&gt;$plans = Invoke-SrmGetAllRecoveryPlans -pairingId $pairingId&lt;/P&gt;&lt;P&gt;$plan = $plans.list | Where-Object { $_.Name -eq "PlanName1" }&lt;/P&gt;&lt;P&gt;$planId = $plan.Id&lt;/P&gt;&lt;P&gt;// Get the current API session&lt;/P&gt;&lt;P&gt;$sessionId = $srmConnection.SessionId&lt;/P&gt;&lt;P&gt;// And use it to construct request headers&lt;BR /&gt;$global:headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"&lt;BR /&gt;$global:headers.Add("x-dr-session", $sessionId)&lt;BR /&gt;$global:headers.Add("Content-Type", "application/json")&lt;/P&gt;&lt;P&gt;// The view mode&lt;BR /&gt;$viewMode = "test"&lt;/P&gt;&lt;P&gt;// Construct the recovery steps URL&lt;BR /&gt;$recoveryStepsUrl = $srmConnection.ServerUri.AbsoluteUri + "api/rest/srm/v2/pairings/${pairingId}/recovery-management/plans/${planId}/recovery-steps/${viewMode}"&lt;/P&gt;&lt;P&gt;// Make the call&lt;BR /&gt;$response = Invoke-RestMethod $recoveryStepsUrl -Method 'GET' -Headers $global:headers&lt;/P&gt;&lt;P&gt;// $response will contain all recovery steps&lt;/P&gt;&lt;P&gt;Some API examples using PowerShell and PowerCLI:&lt;BR /&gt;&lt;A href="https://github.com/vmware-samples/site-recovery-manager-rest-api-examples/tree/main/power-shell" target="_blank"&gt;https://github.com/vmware-samples/site-recovery-manager-rest-api-examples/tree/main/power-shell&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Zdravko Ivanov&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 12:47:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987274#M14289</guid>
      <dc:creator>zivanov</dc:creator>
      <dc:date>2023-09-19T12:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: VMware SDK for SRM - PlanId Query</title>
      <link>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987294#M14291</link>
      <description>&lt;P&gt;Thanks for the awesome response!&lt;/P&gt;&lt;P&gt;I found it easier to get the pairingid like this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$pairingId&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;$pairings&lt;/SPAN&gt;&lt;SPAN&gt;.List.pairingId.Guid&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;instead of:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$pairingId = $srmConnection.ConnectedPairing.PairingId&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;After running the sample code you posted, I got a proper response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;$response = Invoke-RestMethod $recoveryStepsUrl -Method 'GET' -Headers $global:headers -SkipCertificateCheck&lt;BR /&gt;PS /Users/username/Documents/VMwareAPI&amp;gt; $response&lt;/P&gt;&lt;P&gt;list&lt;BR /&gt;----&lt;BR /&gt;{@{plan_callout_position_spec=; vm_callout_position_spec=; title=Synchronize storage; step_number=1.; child_count=6; depth=0; finish_time=; start_time=; expanded=False; id=4254; progress=0; status=INACTIVE; warnings=; errors=; referred_…&lt;/P&gt;&lt;P&gt;I do hope they fix the issue with the PowerCLI cmdlets though.&amp;nbsp; This is a nice workaround.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 13:47:25 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Site-Recovery-Manager/VMware-SDK-for-SRM-PlanId-Query/m-p/2987294#M14291</guid>
      <dc:creator>jaychinut</dc:creator>
      <dc:date>2023-09-19T13:47:25Z</dc:date>
    </item>
  </channel>
</rss>

