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

Extracting Specific String that follows known text

$
0
0

I have a string of text in a file that looks like this (without the extra row space):

{"id":"https://logme.com/id/00DG000000ph8qkrAA/005G00000048CX6IAn","issued_at":"1398557853700","token_type":"Bearer","instance_url":"https://mycompany.my..com","signature":"Oo8VCM9LYJmGEl01VPyJ0OKHbrtsbIsx+LpUCxF8pHU=","access_token":"00DG0000000h8qk!AQQ1QNYIbEAjB63lLkRAA7LsOudy0BoS06K7M08bX2Wm_KXufLA1CHiSet1WStyNSwRlBk38sWQYF6ZIVrrKG5g1CdiHxU_U"}

 

I need to be able to extract JUST the text that follows "access_token": that is in quotes, ie,  

"00DG0000000h8qk!AQQ1QNYIbEAjB63lLkRAA7LsOudy0BoS06K7M08bX2Wm_KXufLA1CHiSet1WStyNSwRlBk38sWQYF6ZIVrrKG5g1CdiHxU_U"

 

I have this code currently to reorganize it:

$header = "ID", "Issued At", "Token Type", "Instance URL", "Signature", "Access Token"

cat token.txt

$t = import-csv token.txt -header $header

$t > token.txt

cat token.txt

------

ID           : {"id":"https://login.salesforce.com/id/00DG0000000h8qkMAA/005G00000048CX6IAM"

Issued At    : issued_at:"1398557853700"

Token Type   : token_type:"Bearer"

Instance URL : instance_url:"https://hpservice.my.salesforce.com"

Signature    : signature:"Oo8VCM9LYJmGEl01VPyJ0OKHbrtsbIsx+LpUCxF8pHU="

Access Token : access_token:"00DG0000000h8qk!AQYAQNYIbEAjB63lLkRAA7LsOudy0BoS06K7M08bX2Wn_KXufLA1CHiSet1WStyNSwRlBk38sWQYF6ZIVrrKG5g1CdiHxU_U"}

but it is not getting me to what I need, which is just that last bit, in a file, WITHOUT the quote (the access token).

 

Any hits on how to extract code "after" a matching, known string?

 

thx

pk

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles