Having trouble connecting to Exchange Online PowerShell

Swist Skutnik 0 Reputation points
2026-11-26T08:32:20.0933333+00:00

Hi everyone,

I'm trying to connect to Exchange Online using the Connect-ExchangeOnline command, but I keep running into an authentication error. What's confusing is that I can sign in to the Microsoft 365 Admin Center with the same account without any issues.

I've also tried closing and reopening PowerShell, but that didn't help. Has anyone run into something similar or know what might be causing this?

Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Vasil Michev 128.8K Reputation points MVP Volunteer Moderator
    2026-11-26T08:37:26.3166667+00:00

    Can you share the full error message?

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-11-26T08:32:38.54+00:00

    If the same account works in the Microsoft 365 admin center but fails in Connect-ExchangeOnline, the most common causes are Exchange Online PowerShell access, authentication method issues, or local PowerShell/module conditions.

    Try this path:

    1. Use modern authentication syntax.
         Connect-ExchangeOnline -UserPrincipalName ******@contoso.onmicrosoft.com
      
      Connect-ExchangeOnline uses modern authentication and works for accounts with or without MFA.
    2. If the connection still fails, verify that the account is enabled for Exchange Online PowerShell access. A successful portal sign-in does not guarantee PowerShell access. One documented cause is that the account does not have access to Exchange Online PowerShell.
    3. Check whether the account is in the correct Exchange admin role group. In the Exchange admin center:
      • permissions
      • admin roles
      • open the required role group, such as Organization Management
      • add the user under Members
      • save the change
    4. If security defaults are enabled in the tenant, use the modern authentication connection method for Exchange Online PowerShell.
    5. Test whether the connection actually succeeded by running an Exchange cmdlet after connecting:
         Get-AcceptedDomain
      
      If no errors appear and the cmdlet returns results, the connection is working.
    6. Check local PowerShell prerequisites if errors continue:
      • PowerShellGet and PackageManagement must be installed for REST-based Exchange Online PowerShell connections.
      • If another module is conflicting, open a new Windows PowerShell window and connect before importing other modules.
    7. Check for profile path issues. Connection commands can fail if the Windows profile path for the account contains special PowerShell characters such as $. The documented workaround is to connect using a different account that does not have special characters in the profile path.
    8. If the error is specifically Bad Request, another administrator may need to enable remote PowerShell for the account:
         Set-User -identity ******@contoso.com -RemotePowerShellEnabled $True
      
      Allow 15–20 minutes for the change to take effect.
    9. If the account uses federated authentication, and the identity provider or STS is not publicly available, a federated account cannot be used for the connection. In that case, use a nonfederated Microsoft 365 account for Exchange Online PowerShell.

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.