Exchange online PS error

Joseph 31 Reputation points
2022-07-04T00:58:11.96+00:00

Hi guys,

I'm fairly new to powershell and not sure what this error might be associated to.

After running Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true command line its returning the error:

PS C:\windows\system32> Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true

New-ExoPSSession : One or more errors occurred.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnlineManagement.psm1:475 char:30

  • ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : NotSpecified: (:) [New-ExoPSSession], AggregateException
  • FullyQualifiedErrorId : System.AggregateException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,502 questions
{count} votes

Accepted answer
  1. KyleXu-MSFT 26,261 Reputation points
    2022-07-04T07:34:02.683+00:00

    @Joseph

    Try to connect to Exchange online with command below:

    Connect-ExchangeOnline -UserPrincipalName admin@domain.onmicrosoft.com  
    

    If there exist issue with it, I would suggest you use command below to uninstall Exchange online module and reinstall it (Run those command in an elevated PowerShell window):

    Uninstall-Module -Name ExchangeOnlineManagement  
    Install-Module -Name ExchangeOnlineManagement  
    

    For EXO V2 module 2.0.5, you also need to check those setting below:

    ExecutionPolicy set as "RemoteSigned" : Set-ExecutionPolicy RemoteSigned

    Basic is enabled on client: winrm get winrm/config/client/auth

    For more detailed information about it, you could have a look about this article.


    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.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Chris Taylor 26 Reputation points
    2022-09-12T21:37:56.11+00:00

    This fixed it for me.

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

    I was seeing this error. For some reason I have to run the command above every time I run powershell and it doesn't save between sessions.

    PS C:\Windows\system32> Connect-ExchangeOnline -UserPrincipalName chris_taylor@craftsamericana0.onmicrosoft.com

    ----------------------------------------------------------------------------

    The module allows access to all existing remote PowerShell (V1) cmdlets in addition to the 9 new, faster, and more reliable cmdlets.

    |--------------------------------------------------------------------------|
    | Old Cmdlets | New/Reliable/Faster Cmdlets |
    |--------------------------------------------------------------------------|
    | Get-CASMailbox | Get-EXOCASMailbox |
    | Get-Mailbox | Get-EXOMailbox |
    | Get-MailboxFolderPermission | Get-EXOMailboxFolderPermission |
    | Get-MailboxFolderStatistics | Get-EXOMailboxFolderStatistics |
    | Get-MailboxPermission | Get-EXOMailboxPermission |
    | Get-MailboxStatistics | Get-EXOMailboxStatistics |
    | Get-MobileDeviceStatistics | Get-EXOMobileDeviceStatistics |
    | Get-Recipient | Get-EXORecipient |
    | Get-RecipientPermission | Get-EXORecipientPermission |
    |--------------------------------------------------------------------------|

    To get additional information, run: Get-Help Connect-ExchangeOnline or check https://aka.ms/exops-docs

    Send your product improvement suggestions and feedback to exocmdletpreview@abdou .microsoft.com. For issues related to the module, contact Microsoft support. Don't use the feedback alias for problems or support issues.

    ----------------------------------------------------------------------------

    Error Acquiring Token:
    System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm

    5 people found this answer helpful.

  2. Amit Singh 4,896 Reputation points
    2022-07-04T06:27:23.183+00:00

    Please try to use the cmdlet as follows:

    Connect-IPPSSession -PSSessionOption  
    $EXOSession = New-ExoPSSession -pssessionoption  
    Import-PSSession $EXOSession -Prefix EXO
    
    1 person found this answer helpful.

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.