Parsing and saving value from SAML response
I am using Invoke-RestMethod to do a POST and would like to parse out a value I am returned. The reply is HTML with a bunch of stuff but I only care about this part and what is supplied as the value:
<form id="SamlForm" method="post">
<input name="RelayState" id="RelayState" type="hidden" />
<input name="SAMLResponse" id="SAMLResponse" type="hidden" value="theTextIwant..." />
Any help is appreciated.
Posted Apr 12, 2021, 5:19 PM UTC · edited
27
Its plain XML so [xml]
Sorry can you expand on that more? This is definitely not my forte as you can tell.
https://adamtheautomator.com/powershell-parse-xml/
[Xml]$xml =$saml
Unfortunately this doesn't work as the POST response is much more than the simple info I supplied in the original post. And some of the returned values syntax breaks the XML parser. I was thinking some regex to pull the value out.
If you extract the assertion it must be xml. Otherwise its not standard saml.
With regex you xan achieve the same, its just not so straightforward.