"Connect-MsolService: Exception of type was thrown" when you use the connect-MSOLService to connect to Microsoft 365, Azure, or Intune

Problem

When you try to use the connect-MSOLService cmdlet in the Microsoft Azure Active Directory Module for Windows PowerShell to connect to a Microsoft cloud service such as Microsoft 365, Azure, or Microsoft Intune, your attempt is unsuccessful. You may also receive the following error message:

Connect-MsolService: Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.

Cause

This issue may occur for one or more of the following reasons:

  • The Azure Active Directory Module for Windows PowerShell rich client can't connect to the service. This is frequently the result of client computer readiness issues.
  • The user ID that's used to authenticate is single sign-on (SSO)-enabled, and a client computer problem is preventing SSO communication with Active Directory Federation Services (AD FS), with the Azure Active Directory authentication system, or with both.

Solution

To resolve this issue, follow these steps:

  1. Troubleshoot Microsoft 365 rich client connectivity. For more information, see How to troubleshoot non-browser apps that can't sign in to Microsoft 365, Azure, or Intune.
  2. Troubleshoot common client configuration issues that limit SSO authentication. For more information, see Signing in to Microsoft 365, Azure, or Intune by using single sign-on doesn't work from some devices.

More information

For more information about Azure Active Directory Module for Windows PowerShell, see Azure Active Directory Cmdlets.

Still need help? Go to Microsoft Community or Azure Active Directory Forums website.