0

I can query the VPN users of our firewall via API-Call in Chrome.
https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000Clor

I would like to use result.content as XML in Powershell to work with the objects.

$url=https://localfirewall.domain.tld/api/?type=op&cmd=<show><global-protect-gateway><current-user></current-user></global-protect-gateway></show>&verysecretapikey=
$result=invoke-webrequest -uri $url -skipcertificatechek -method:get -contenttype "application/xml
$result.content

In PaloAlto's KB article you can see the output of the call in the browser.

2
  • 1
    $result.content -as [xml] should do Commented Feb 8, 2022 at 10:59
  • Perfect! Thank you! $result= (result.content -as [xml]).response.result.entry does the job! Commented Feb 8, 2022 at 11:23

1 Answer 1

2

A string containing well-formed xml is implicitly parsed if you simply convert it to the [xml] type:

# using the `-as` conversion operator
# this will silently return $null on failure to parse the document
$xmlDocument = $result.content -as [xml]

# using a cast operation
# this will throw on failure to parse the document
$xmlDocument = [xml]$result.content
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.