I have a powershell script, and at the beginning it sets AWSCredential, like below:
Set -AWSCredentials -profileName myProfileName
In the same script, I have a line that should only execute if the profile above is logged in successfully, otherwise don't execute that line.
How do I check that, that it logged in ok
(If logged in ok) { Execute my line here }
CodePudding user response:
You can get sts details of the account,
if (aws sts get-caller-identity) { do the stuff }