Fix Connect-MsolService Authentication Errors with AD FS
Question details
Determine why a federated user cannot authenticate with Connect-MsolService even though the same credentials work in Microsoft 365 portals.

- Product
- Microsoft 365, Microsoft Entra ID, AD FS, and MSOnline PowerShell
- Device & OS
- not provided
- Scenario
- A federated user attempts to connect to Microsoft 365 using the Connect-MsolService PowerShell command.
- Observed behavior
- Connect-MsolService reports that it cannot authenticate the credentials, while portal sign-in and other PowerShell sessions work.
Identify the affected user's federated UPN and note the time of a failed sign-in so an administrator can find the relevant logs. Check whether the tenant uses AD FS federation and whether cloud-only accounts can connect.
Check MSOnline retirement and use Microsoft Graph PowerShell
Use this approach first because the retired MSOnline module is not a reliable long-term connection method.
Microsoft retired the MSOnline PowerShell module in 2025. A Connect-MsolService failure may therefore be related to service retirement rather than an AD FS configuration error. Microsoft Graph PowerShell is the supported replacement for many, but not necessarily all, MSOnline tasks.
In PowerShell, run Get-Module MSOnline -ListAvailable to identify any installed MSOnline versions. Do not assume that updating the retired module will restore service access.
In PowerShell, run Install-Module Microsoft.Graph -Scope CurrentUser if the Microsoft Graph module is not already installed.
Run Connect-MgGraph with the delegated scopes needed for your task, such as Connect-MgGraph -Scopes "Domain.Read.All" for reading domain federation configuration. Complete the sign-in prompt and obtain administrator consent if required.
Use Get-Command -Module Microsoft.Graph* to explore available Graph commands, or consult Microsoft's MSOnline-to-Microsoft Graph migration guidance for the specific task you previously performed with MSOnline.

Verify the federated UPN and synchronization status
Use these checks when the affected account is synchronized from on-premises Active Directory.
Review AD FS endpoints, certificates, and sign-in logs
Use this solution to investigate federation configuration when supported federated authentication requests also fail.
Document AD FS Troubleshooting in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing troubleshooting documents and spreadsheets. It does not repair AD FS or replace Microsoft Entra administration tools.

Frequently Asked Questions
Why can I sign in to Microsoft 365 but not Connect-MsolService?
Portal sign-in and legacy PowerShell authentication can use different authentication paths. The MSOnline module was also retired in 2025, so its failure does not by itself prove that the password or AD FS is incorrect.
What should I use instead of Connect-MsolService?
For many tasks, install Microsoft Graph PowerShell with Install-Module Microsoft.Graph -Scope CurrentUser, then connect with Connect-MgGraph and the scopes required for your task. Check Microsoft's migration guidance for the equivalent command.
Where can I find details of the failed federated sign-in?
In the Microsoft Entra admin center, open Identity > Monitoring & health > Sign-in logs and filter by user and time. On an AD FS server, check Event Viewer under Applications and Services Logs > AD FS.
How do I check the AD FS token-signing certificate?
On an AD FS server, run Get-AdfsCertificate -CertificateType Token-Signing. Check the certificate's validity and compare the primary signing certificate with the federation configuration registered in Microsoft Entra ID.
Should I enable all WS-Trust endpoints to fix the error?
No. Run Get-AdfsEndpoint on the AD FS server and determine which endpoints the affected client actually requires. Enabling or exposing unnecessary endpoints can increase security risk.




