Cannot connect Exchange online with Powershell

Pekka Pekkonen 576 Reputation points
2021-08-27T12:26:06.587+00:00

Hello

I have a problem to connect to Exchange online with a global admin account (MFA enabled).

Here are the errors I get:
1st error
New-ExoPSSession : Processing data from remote server outlook.office365.com failed with the following error message: Th
e request for the Windows Remote Shell with ShellId 4BC388B1-124B-41D9-87B9-42D6BD57990A failed because the shell was n
ot found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the se
rver. Provide the correct ShellId or create a new shell and retry the operation. For more information, see the about_Re
mote_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.Exchang
    e.Management.ExoPowershellSnapin.NewExoPSSession

2nd error
New-ExoPSSession : Processing data from remote server outlook.office365.com failed with the following error message: [A
uthZRequestId=f2baaa6c-ce5d-4bbc-aa13-d4457901547f][FailureCategory=AuthZ-CmdletAccessDeniedException] The user "EURP19
0A003.PROD.OUTLOOK.COM/Microsoft Exchange Hosted Organizations/xxx.onmicrosoft.com/xxx" isn't assigne
d to any management roles. 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.Exchang
    e.Management.ExoPowershellSnapin.NewExoPSSession

127128-image.png

So far I have tested with other network and other computer with same kind results. I have the problem with several tenants and it has lasted at least a week.

One work around is that I can create a new global admin. With that it seems to work normally. But would there be possibilities to retain the original admin access?

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

Accepted answer
  1. Pekka Pekkonen 576 Reputation points
    2021-08-30T13:36:27.72+00:00

    Hello

    Thank you @Xzsssss for the response. Here are further details.

    It should be cloud-only and non-multi-region tenant. I get the second error over and over again, so trying another time does not seem to help either.

    I also tried to remove GA rights and add them again but the error still keeps coming.

    I hope these clarified the issue.

    [Edit: ZhengqiLou-MSFT provided the solution in the comments]

    Regards,
    Pekkapek

    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Xzsssss 8,861 Reputation points Microsoft Vendor
    2021-08-30T06:32:43.663+00:00

    Hi @Pekka Pekkonen ,

    For the first error, please check this document for help: https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/invalidshellid-error-in-rps
    See the scenario two: In this scenario, you should rerun the cmdlet. A different back-end server should be contacted, and then the cmdlet should run successfully.

    For the second one, as it points out the "XXX isn't assigned to any management roles.", I think it's a permission mistake.
    As you said you used a GA account to login the Exchange Online PowerShell and failed, but new created GA could work correctly. Would you like to share something about your environment? Is it a hybird and the former GA account lives on-prem?

    Also please try re-assign permission to the former account, and see if this time it could work or not.

    Best regards,
    Lou


    If the response is helpful, please click "Accept Answer" and upvote it.
    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.

    0 comments No comments

  2. Avi Luintel 1 Reputation point Microsoft Employee
    2022-02-24T15:11:55.86+00:00

    I am experiencing the same issue. The language setting does not seem to be an issue at my end as English is set as default language. Please, suggest..

    New-ExoPSSession : Connecting to remote server <URL> failed with the following error message : For more
    information, see the about_Remote_Troubleshooting Help topic.
    At C:\Users\<username omittedhere >\Documents\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnl
    ineManagement.psm1:475 char:30

    • ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
    • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : ResourceUnavailable: (:) [New-ExoPSSession], PSRemotingTransportException
    • FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.Exchang
      e.Management.ExoPowershellSnapin.NewExoPSSession

  3. Avi Luintel 1 Reputation point Microsoft Employee
    2022-02-25T21:04:02.97+00:00

    Hi Steven,
    I am supposed to use v5 at my workplace. I even tried uninstalling and reinstalling of exchange module but without any luck.

    0 comments No comments

  4. Avi Luintel 1 Reputation point Microsoft Employee
    2022-03-01T21:20:36.79+00:00

    I was able to figure out the solution.

    Steps:

    1. Displays remotepowershell status: In my case it showed false

    Get-User -Identity <UserIdentity> | Format-List RemotePowerShellEnabled

    2) Now enable the remotepowershell for exchange online
    Set-User -Identity <UserIdentity> -RemotePowerShellEnabled $true

    3) validate: run step 1 and it should display true. I was then able to connect to exchange online through powershell

    Hope it helps to those who have same issues.

    0 comments No comments