unable to connect to exchange online powershell module

Roger Roger 7,161 Reputation points
2021-08-26T19:09:53.313+00:00

Hi All

i am getting below error when connecting to exchange online PowerShell module.
I have global admin rights and also i have Organization Management admin role in exchange admin center.

Install-Module -Name ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

PS C:\windows\system32> $UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
At line:2 char:12

  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
  • FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
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,959 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,915 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dimitri Schrader 86 Reputation points
    2021-08-26T19:45:09.717+00:00

    Is there a reason you are not using the Connect-ExchangeOnline commandlet?

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

    https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Kael Yao 37,746 Reputation points Moderator
    2021-08-27T05:22:33.383+00:00

    Hi @Roger Roger

    It seems you are trying to use basic authentication to connect to EXO powershell.
    Please note that basic authentication is a less secure authentication method and is suggested to be turned-off in your Microsoft 365 tenants.

    As DimitriS suggested, please consider using modern auth to connect to EXO powershell.


    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.


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.