This has been an ongoing problem since ADFS was released for Office 365. I am glad to see that Microsoft has finally resolved the issue without having to completely open up your firewall with the WinRM command.
The following content was copied and pasted from the KB above.
When you run the Set-MsolADFSContext -Computer cmdlet in the Microsoft Online Services Module for Windows PowerShell, you receive the following error:
Set-MsolADFSContext : The connection to <ServerName> Active Directory Federation Services 2.0 server failed due to invalid credentials.
This error occurs because Remote PowerShell is not enabled on the Active Directory Federation Services (AD FS) 2.0 federation server that the -computer parameter references.
When a domain is added correctly and verified in the Microsoft Office 365 portal, you can use the Microsoft Online Services Module for Windows PowerShell to configure Office 365 identity federation from a management workstation by using Remote PowerShell.
However, the Microsoft Online Services Module for Windows PowerShell can only be installed on Windows 7 and on Windows Server 2008 SR2. The Microsoft Online Services Module for Windows PowerShell cannot be installed on Windows Server 2008 Service Pack 2 (SP2). Therefore, this problem is especially relevant where AD FS 2.0 is installed on a Windows Server 2008 SP2 platform. In this case, the Microsoft Online Services Module for Windows PowerShell command that is related to AD FS 2.0 must be issued from a remote computer.
To enable Remote PowerShell on the AD FS 2.0 federation server, follow these steps:
Start Windows PowerShell as an administrator. To do this, right-click the Windows PowerShell shortcut, and then click Run As Administrator.
To configure Windows PowerShell for remoting, type the following command, and then press ENTER:
Thanks for visiting and reading my posts. I am always looking for more ideas. Please comment or email me with what you would like to see.
Office 365 MVP