Connect to ExchangeOnlineManagement powershell module returns error

KimH 5 Reputation points
2025-04-25T19:04:17.0266667+00:00

Script is called from Workato, and runs from a virtual machine that has exchange online 3.6.0. This was working up until last week.

UnAuthorized

At C:\Program

Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.6.0\netFramework\ExchangeOnlineManagement.psm1:766 char:21

  •                 throw $_.Exception;
    
  •                 ~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (:) [], UnauthorizedAccessException
    • FullyQualifiedErrorId : UnAuthorized

When updating to exchange module 3.7.2 I see this error:

Error Acquiring Token: Unknown Status: Unexpected Error: 0xffffffff80070520 Context: (pii) Tag: 0x21420087 (error code -2147023584) (internal error code 557973639) Unknown Status: Unexpected Error: 0xffffffff80070520 Context: (pii) Tag: 0x21420087 (error code -2147023584) (internal error code 557973639) At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.7.2\netFramework\ExchangeOnlineManagement.psm1:754 char:21 + throw $_.Exception.InnerException; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], MsalServiceException + FullyQualifiedErrorId : Unknown Status: Unexpected Error: 0xffffffff80070520 Context: (pii) Tag: 0x21420087 (error code -2147023584) (internal error code 557973639)

Windows for business | Windows Server | User experience | PowerShell

2 answers

Sort by: Most helpful
  1. Smith Pham 2,795 Reputation points Independent Advisor
    2025-05-07T10:34:09.26+00:00

    Dear Team,

    You will need to run the Enable to TLS 1.2

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    .

    Here is the script:

    # Set TLS 1.2
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
    # Import module
    Import-Module ExchangeOnlineManagement -RequiredVersion 3.6.0
    
    # Connect to Exchange Online
    try {
        Connect-ExchangeOnline -AppId "<ClientID>" -CertificateThumbprint "<Thumbprint>" -Organization "<Tenant>.onmicrosoft.com" -Verbose
        Write-Host "Connected successfully!"
        # Test a command
        Get-EXOMailbox -ResultSize 1
    } catch {
        Write-Host "Error: $_"
    } finally {
        Disconnect-ExchangeOnline -Confirm:$false
    }
    
    

    Was this answer helpful?


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.