title: AWS PowerShell Use-STSRole : The security token included in the request is invalid
body: <p>In my Jenkins build job I'm using this command to assume an AWS role:</p>
  
  <pre><code>$Creds = (Use-STSRole -Region us-east-1 -RoleArn arn:aws:iam::$IAM_ACCOUNT_ID`:role/$IAM_ROLE -RoleSessionName jenkins).Credentials
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <blockquote>
    <p>Use-STSRole : The security token included in the request is invalid.</p>
  </blockquote>
  
  <p>Changing the AWS Role to an invalid role does not change the error message. </p>
  
  <p>It works fine when logging into the server and using the command in Powershell directly. </p>
  
  <p>It also works if I use a AWS CLI command:</p>
  
  <pre><code>aws sts assume-role --role-arn arn:aws:iam::%IAM_ACCOUNT_ID%:role/%IAM_ROLE% --role-session-name jenkins-deploy
  </code></pre>
  
  <p>Full error message:</p>
  
  <pre><code>Use-STSRole : The security token included in the request is invalid.
  At C:\Users\svc-jenkins.WIN-KLBFC355P8D\AppData\Local\Temp\jenkins4822311255190032778.ps1:5 char:11
  + $Creds = (Use-STSRole -Region us-east-1 -RoleArn arn:aws:iam::$e ...
  +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (Amazon.PowerShe...seSTSRoleCmdlet:UseSTSRoleCmdlet) [Use-STSRole], InvalidOperationException
      + FullyQualifiedErrorId : Amazon.SecurityToken.AmazonSecurityTokenServiceException,Amazon.PowerShell.Cmdlets.STS.UseSTSRoleCmdlet
  </code></pre>