Cannot connect Exchange online with Powershell - No error message provided

Patrick McAuliffe 30 Reputation points
2023-08-11T02:04:31.0266667+00:00

I have version '2.0.5' of module 'ExchangeOnlineManagement' installed. I running Powershell 7 as administrator.

I used to be able to connect to exchange online using the command -

"Connect-ExchangeOnline -UserPrincipalName ******@contoso.onmicrosoft.com"

This method no longer works and I do not see a specific error message. Just the following,

"Exception: Connecting to remote server outlook.office365.com failed with the following error message : For more information, see the about_Remote_Troubleshooting Help topic."

It seems the error message is missing. When attemping to do the same on the standard powershell I get error mesage,

"

New-ExoPSSession : Connecting to remote server outlook.office365.com failed with the following error message :  For more information, see the about_Remote_Troubleshooting Help topic.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnlineManagement.psm1:475 char:30
+ ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [New-ExoPSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession

Do I need to install module 3.2.0?

It has been over 3 months since I have used this feature.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao 37,746 Reputation points Moderator
    2023-08-11T02:51:33.12+00:00

    Hi @Patrick McAuliffe

    Here is a similar thread for your reference:

    New-ExoPSSession : Connecting to remote server outlook.office365.com failed with the following error message : For more information, see the about_Remote_Troubleshooting Help topic.

    In short, the cause may be due to RPS is disabled in your tenant.

    Exchange blog link with detailed information:

    Deprecation of Remote PowerShell in Exchange Online – Re-enabling or Extending RPS support

    Since the V2 module would no longer work after RPS is completely turned off, please consider updating to V3 module.

    Thanks for your understanding.


    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 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Charles Queen 10 Reputation points
    2023-12-21T14:31:19.2933333+00:00

    For anyone else that comes across this, apparently the UPN alone cannot be used to automatically determine the correct Exchange Organization. You have to explicitly provide it if you aren't using a certificate to authenticate. Also, like was mentioned, make sure you are using V3:

    Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.4.0 (or greater)  
    

    In OP's case, the command would be:

    Connect-ExchangeOnline -UserPrincipalName ******@contoso.onmicrosoft.com -Organization contoso.onmicrosoft.com
    
    2 people found this answer helpful.
    0 comments No comments

Your answer

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