title: powershell credential rejected from server
body: <p>I need to store credential in powershell to be used several times. Here on StackOverflow there are a lot of example, so I took one</p>
  
  <pre><code>$tmpCred = Get-Credential
  $tmpCred.Password | ConvertFrom-SecureString | Set-Content "pwd.dat"
  $password = Get-Content "pwd.dat" | ConvertTo-SecureString
  $credential = New-Object System.Management.Automation.PsCredential "myDomain\myUser", $password
  
  Get-ADUser -Credential $credential 
  </code></pre>
  
  <p>Unfortunately I get this error and I can't find a solution</p>
  
  <pre><code>Get-ADUser : The server has rejected the client credentials.
  At line:5 char:11
  + Get-ADUser &lt;&lt;&lt;&lt;  "xxx" -Credential $credential 
      + CategoryInfo          : NotSpecified: (xxx:ADUser) [Get-ADUser], AuthenticationException
      + FullyQualifiedErrorId : The server has rejected the client credentials.,Microsoft.ActiveDirectory.Management.Commands.GetADUser
  </code></pre>