Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Windows instance run the following PowerShell command:

Invoke-RestMethod http://100.100.100.200/latest/meta-data/ram/security-credentials/EcsRamRoleDocumentTesting

then it will Obtain a temporary authorization Token result:

{
"AccessKeyId" : "<youraccesskeyid>",
"AccessKeySecret" : "<youraccesskeysecret>",
"Expiration" : "2017-11-01T05:20:01Z",
"SecurityToken" : "<yoursecuritytoken>",
"LastUpdated" : "2017-10-31T23:20:01Z",
"Code" : "Success"
}


I would like to know How to export the the result to one txt file with below format:

[Credentials]
language=EN
endpoint=ABCD
accessKeyID=<youraccesskeyid>
accessKeySecret=<youraccesskeysecret>
stsToken=<yoursecuritytoken>

and this powershell will run every hours and every time need to overwite the result in txt file.

What I have tried:

run the powershell is no problem, need to export the result.
Posted
Updated 26-May-22 2:46am

1 solution

 
Share this answer
 
Comments
Silver Lu 27-May-22 0:59am    
after output to file
"AccessKeyId" : "<youraccesskeyid>",
"AccessKeySecret" : "<youraccesskeysecret>",

how to get-content from file just with <youraccesskeyid> and <youraccesskeysecret>
Richard MacCutchan 27-May-22 3:40am    
Sorry, I do not understand the question.
Silver Lu 30-May-22 21:37pm    
I mean remove "AccessKeyId" : and "AccessKeySecret" :

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900