The connection to Active Directory Federation Services 2.0 server failed due to invalid credentials


Are you getting a “failed due to invalid credentials” in PowerShell when executing Set-MsolADFSContext?

PS C:\Windows\system32> Set-MsolADFSContext -Computer 
Set-MsolADFSContext : The connection to Active Directory 
Federation Services 2.0 server failed due to invalid credentials.

Try the following:

    1. Start Windows PowerShell as an administrator and set up Windows PowerShell for remoting by typing Enable-PSRemoting –force
    2. Open port 5985 on your server firewall.
    3. Make sure to specify a logfile when entering the command:

Set-MsolADFSContext -Computer -logfile c:\log.txt

  1. Telnet from a remote location to the ADFS server on port 5985, a blinking cursor is good.
  2. In case this is a server hosted in Azure, configure an endpoint:



Consider leaving a reply in case this post helped you. Thanks!

Read 196 times
Dylan Austin


Whenever I have a problem, I sing. Then I realize my voice is worse than my problem.

We use cookies to improve our website. By continuing to use this website, you are giving consent to cookies being used. More details…