Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

PSCustomObject NoteProperty Stuck...

$
0
0

Hi,

 

I am struggling to extract the string from a NoteProperty returned within a PSCustomObject.

 

I am looking to query a API from Cisco (Cisco PSIRT openVuln). I have managed to authenticate using the following code:

 

 

$client_id = "client_id-removed"

$client_secret = "client_secret_removed"

 

$tokenParams = @{

client_id=$client_id;

client_secret=$client_secret;

grant_type="client_credentials"

}

 

$token = (Invoke-WebRequest -contenttype "application/x-www-form-urlencoded" -Uri "https://cloudsso.cisco.com/as/token.oauth2" -Method POST -Body $tokenParams)

 

$token.AllElements | get-member

 

 

Which (obviously with the correct client_id & client_secret values) returns the API session token in a NoteProperty as a string, like this:

 

 

   TypeName: System.Management.Automation.PSCustomObject

 

Name        MemberType   Definition                                                                                                                                        

----        ----------   ----------                                                                                                                                        

Equals      Method       bool Equals(System.Object obj)                                                                                                                    

GetHashCode Method       int GetHashCode()                                                                                                                                 

GetType     Method       type GetType()                                                                                                                                    

ToString    Method       string ToString()                                                                                                                                 

innerHTML   NoteProperty string innerHTML=<HEAD></HEAD>...                                                                                                                 

innerText   NoteProperty string innerText={"access_token":"Vo5MtBD7AvgcdwF3U5hwj83wskiw","token_type":"Bearer","expires_in":3599}                                          

outerHTML   NoteProperty string outerHTML=<HTML><HEAD></HEAD>...                                                                                                           

outerText   NoteProperty string outerText={"access_token":"Vo5MtBD7AvgcdwF3U5hwj83wskiw","token_type":"Bearer","expires_in":3599}                                          

tagName     NoteProperty string tagName=HTML

 

 

I am stuck on how to extract InnerText as variables (access_token, token_type, etc)

 

I would appreciate any help you can offer.

 

Many Thanks

Martin

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles