0

I have a REST response which sets a variable as shown below:

PS H:> echo $response

Success

------- @{count=1; uri=https://server/results/Success}

I can also do:

PS H:> echo $response.Success.uri

https://server/results/Success

I need the uri. However it may possibly at times be on $response.Fail.uri or $response.Error.uri instead of $response.Success.uri

Must all the variants be check in PowerShell separately or is there a way to extract uri regardless of Fail, Response or Success ?

EDIT:

PS H:> Write-Host $response | fl * -f

@{Success=}

4
  • 1
    Take a look at the output using $response | fl * -f and see whether the uri is present on a top level. Commented Feb 3, 2017 at 11:14
  • No it's not on the top level (see edit) Commented Feb 3, 2017 at 11:30
  • So the answer is probably no. But if you give us access to the ressource we can check it. Commented Feb 3, 2017 at 11:34
  • It's not a public resource so (physically) unable to grant access. Commented Feb 3, 2017 at 11:43

1 Answer 1

1

Try this:

$response | Select-Object -ExpandProperty "*" | Select-Object uri

This assumes a few things about your response structure, but might help steer you down the right path!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.