Unable to connect exchange online via PowerShell Cmdlet.

Chamnarn Tantithamthiti 20 Reputation points
2026-02-04T05:58:55.99+00:00

Dear Team,

I unable connect to exchange management online via PowerShell Portal. Detail on below shown.

PS C:\windows\system32> Connect-ExchangeOnline

Error Acquiring Token:

Unknown Status: Unexpected

Error: 0xffffffff80070520

Context: A specified logon session does not exist. It may already have been terminated.

Tag: 0x21420087 (error code -2147023584) (internal error code 557973639)

Unknown Status: Unexpected

Error: 0xffffffff80070520

Context: A specified logon session does not exist. It may already have been terminated.

Tag: 0x21420087 (error code -2147023584) (internal error code 557973639)

At C:\Program

Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.9.2\netFramework\ExchangeOnlineManagement.psm1:591 char:21

  •                 throw $_.Exception.InnerException;
    
  •                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (:) [], MsalServiceException
    • FullyQualifiedErrorId : Unknown Status: Unexpected

Error: 0xffffffff80070520

Context: A specified logon session does not exist. It may already have been terminated.

Tag: 0x21420087 (error code -2147023584) (internal error code 557973639)

However, I have already cmdlet Disconnect-ExchangeOnline -Confirm:$false and close powershell and try connect again found unable connect to exchange online too.

Could you please help me solved the issue.

Thank you.

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

Answer accepted by question author
Anonymous
2026-02-04T06:43:12.79+00:00

Dear @Chamnarn Tantithamthiti,

Welcome to Microsoft Q&A Forum!

Thank you for sharing the error details. Based on my research, this issue may cause in the latest ExchangeOnlineManagement module versions >=3.7.0. To resolve the problem, please remove the version you have installed and try the module in version 3.6.0 using the following commands:

Uninstall-Module ExchangeOnlineManagement
Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.6.0
Get-InstalledModule ExchangeOnlineManagement

Reference: https://learn.microsoft.com/en-us/answers/questions/2145959/how-to-fix-error-acquiring-token

I hope this information can help you and please feel free to update to me in comment section. Wish you a good day!


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-02-04T05:59:04.3933333+00:00

    The error you are encountering when trying to connect to Exchange Online via PowerShell indicates that there is an issue with the Windows Authentication Model (WAM) integration. Specifically, the error message suggests that the logon session may not exist or has been terminated, which can occur if you are running PowerShell under a different user context than the one used to sign in to Windows.

    To resolve this issue, consider the following steps:

    1. Run PowerShell in the same context as the signed-in Windows user. This ensures that WAM can function correctly and access the necessary credentials.
    2. Avoid using the RunAs option to run PowerShell commands, as this can isolate the session and prevent WAM from working properly.
    3. If you need to connect without WAM, you can temporarily disable it by using the -DisableWAM parameter with the Connect-ExchangeOnline command:
         Connect-ExchangeOnline -UserPrincipalName <yourUPN> -DisableWAM
      
      Replace <yourUPN> with your actual user principal name.
    4. Ensure that your account has the RemotePowerShellEnabled parameter set to True. If not, another administrator can enable it using the following command:
         Set-User -identity ******@contoso.com -RemotePowerShellEnabled $True
      
      Allow some time for the changes to take effect before attempting to connect again.

    If these steps do not resolve the issue, you may want to check for any other underlying problems, such as network issues or service availability.

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

    Was this answer helpful?

    1 person found 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.