How can I reliably connect to Exchange Online PowerShell when the module keeps timing out or dropping the session?

Wilder Kimeya 20 Reputation points
2025-12-11T08:52:54.5433333+00:00

I’m trying to manage mailboxes through Exchange Online PowerShell, but recently my connections either hang at “Connecting…” or disconnect after a few minutes, even though my network is stable and I’m using the latest ExchangeOnlineManagement module.

Is there a recommended way to check whether this issue comes from my client setup, the module version, or something on the tenant side?

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
{count} votes

Answer accepted by question author
  1. Steven-N 15,160 Reputation points Microsoft External Staff Moderator
    2025-12-11T09:47:46.48+00:00

    Hi Wilder Kimeya

    Based on your description, I understand that Connect-ExchangeOnline intermittently hangs at “Connecting” or disconnects after a few minutes even though the network is stable and you’re using the latest ExchangeOnlineManagement (EXO V3) module. You want the recommended way to isolate whether the issue is client setup, module/version behavior, or tenant-side policies/service health.

    In this situation, I recommend you can follow the some approaches below to see if it can resolve your problem:

    Baseline the client and EXO module

    Confirm prerequisites and load path; EXO V3 requires PowerShellGet + PackageManagement for REST connections. Update the module and dependencies, and avoid multiple EXO versions installed side-by-side.

    Get-InstalledModule ExchangeOnlineManagement
    Get-Module ExchangeOnlineManagement -ListAvailable
    Get-InstalledModule PowerShellGet, PackageManagement
    

    Validate authentication flow and test with and without WAM

    Start with the default (WAM-enabled) flow:

    Connect-ExchangeOnline -UserPrincipalName <UPN> -ShowBanner:$false
    

    If it still hangs, run a temporary diagnostic using -DisableWAM (do not keep long-term), this helps isolate WAM/broker/profile context issues.

    Connect-ExchangeOnline -UserPrincipalName <UPN> -DisableWAM -ShowBanner:$false
    

    Refresh Module + Token Cache (Clean Client Environment)

    Failures often occur due to mixed module versions, outdated dependencies, or stale authentication tokens.

    Run:

    Uninstall-Module ExchangeOnlineManagement -AllVersions
    Install-Module ExchangeOnlineManagement
    Update-Module PowerShellGet
    Update-Module PackageManagement
    Remove-Item "$env:LOCALAPPDATA\Microsoft\PowerShell\TokenCache\*" -Recurse -Force
    

    Hope my answer will help you, for any further concern, kindly let me know in the comment section.


    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.


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-11T08:53:09.1333333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To reliably connect to Exchange Online PowerShell and address issues with timeouts or dropped sessions, consider the following recommendations:

    1. Update the Module: Ensure you are using the latest version of the Exchange Online PowerShell module. You can check your current version and update it using the following commands:
         Get-InstalledModule ExchangeOnlineManagement | FL Name,Version,InstalledLocation
         Update-Module -Name ExchangeOnlineManagement
      
    2. Session Management: Use the Disconnect-ExchangeOnline cmdlet to clean up sessions properly. This can help avoid issues with lingering sessions that may cause timeouts.
    3. Check Execution Policy: Ensure that your PowerShell execution policy is set to RemoteSigned. You can set it by running:
         Set-ExecutionPolicy RemoteSigned
      
    4. Network Configuration: Although you mentioned your network is stable, ensure that there are no firewall or proxy settings that might interfere with the connection. Check if any specific ports required for PowerShell remoting are blocked.
    5. Use Diagnostic Logging: Collect diagnostic logs by using the -EnableErrorReporting parameter with the Connect-ExchangeOnline command. This can provide insights into what might be causing the connection issues.
    6. Consider WAM Integration: If you are using Windows Authentication Manager (WAM), be aware that it may cause issues in certain scenarios. If you suspect this is the case, try disabling WAM temporarily to see if it resolves the connection problems.

    By following these steps, you should be able to identify whether the issue is related to your client setup, the module version, or something on the tenant side.


    References:

    0 comments No comments

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.