How to get AWS account ID from curl in powershell

Does anyone know how to get the AWS account id in powershell?, I would like to do the this from the curl command, and have this running well under linux from here:,%2Finstance%2Didentity%2Fdocument.&text=This%20gives%20me%20%22Unable%20to,running%20%22aws%20configure%22.%22

Specifically this:

curl -s | sed -nE 's/.*"accountId"\s*:\s*"(.*)".*/\1/p'

And I can use the curl command in windows get get the same output but without parsing like this


but I have no idea how to parse and get just the accountId number, or the instanceId if I need that..

I have tried the Select statement, but get no meaningful results.

Any help would be appreciated.

Thanks in advance..

>Solution :

You can use:

$account_id = ((curl | ConvertFrom-Json).accountId

Leave a Reply