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.