title: Handling XML Data from WebRequest in Powershell
body: <pre><code>$uri = "https://${server}/api/${api_version}/xml"
  $login_request = "&lt;LoginRequest password ='$pwd' user-id = '$user' &gt;&lt;/LoginRequest&gt;"
  $resp = Invoke-WebRequest -URI $uri -Body $login_request -ContentType 'text/xml' -Method post
  [xml]$xmldata = $resp.content
  if($xmldata.LoginResponse.success -eq '0'){
      Write-Host 'ERROR: '$xmldata.LoginResponse.Failure.message -ForegroundColor Red
      }
      Else{
      $SCRIPT:session_id = $xmldata.LoginResponse.'session-id'
      Write-Host "Login Successful" -ForegroundColor Green
      }
  $disc_request = "&lt;DiscoveryConnectionListingRequest session-id='$SCRIPT:session_id'/&gt;"
  $resp_disc = Invoke-WebRequest -URI $uri -Body $disc_request -ContentType 'text/xml' -Method post
  [xml]$xmldata = $resp_disc.content
  $xmldata.DiscoveryConnectionListingResponse.DiscoveryConnectionSummary
  </code></pre>
  
  <p>This returns about 30 of these:</p>
  
  <pre><code>connection-status : Connected
  id                : 58
  name              : server1
  engine-id         : 59
  
  connection-status : Disconnected
  id                : 57
  name              : server2
  engine-id         : 61
  </code></pre>
  
  <p>I'm having a real tough time figuring out how to go through this data and figure out if any of the 'connection-status' is 'disconnected'.  I would use the same logic to determine if the engine-id is 0 or 1.  Can anyone here point me in the right direction?</p>