1 Reply Latest reply on Feb 3, 2017 8:55 AM by dtaliafe

    REST API

    JimKnopf99 Master

      Hi,

       

      i have a question about the REST API. I would like to add a VM into Maintenace mode during backup time. I create the following script.

       

      $vrealize = "vrealize"

      $username = "maintenance";

      $password = ConvertTo-SecureString –String "password" –AsPlainText -Force

      $credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $username, $password

       

      $data = Invoke-RestMethod -Method Get -uri "https://$vrealize/suite-api/api/resources/" -Credential $credential

       

      #Put in Maintenance Mode

      Invoke-RestMethod -Method Put -uri "https://$vrealize/suite-api/api/resources/"VMname"/maintained" -Credential $credential

       

      #Remove from Maintenance Mode

      Invoke-RestMethod -Method delete -uri "https://$vrealize/suite-api/api/resources/"VMname"/maintained" -Credential $credential

       

      The Script is working. The question is, if i have multiple adapters, like the End Point Agent Adapter, i also have multiple entries of my vm´s when browsing the inventory explorer.

      One for vCenter Adapter and multiple entries for EP Ops Adapter. One Agent Entry, one Windows or Linux entry and one MSSQL entry if it is installed on the VM.

       

      With the script above, it is only possible to add the vm that is located under the vcenter adapter into maintenance.

      How is it possible to find the id for the other adapters to add the vm for all installed adapters into maintenance?

       

      Thanks

      Frank