Can't connect to exchange online using powershell with global admin rights

lalajee 1,821 Reputation points
2022-06-13T09:03:27.647+00:00

Hi, I have Global Admin rights on azure

When I try below come powershell code to connect to office 365

$UserCredential = Get-Credential -UserName "******@domain.com" -Message "Username and Password"  
  
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection  
  
Import-PSSession $Session  

I get following error message

Import-PSSession $Session  
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:3 char:12  
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...  
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException  
    + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed  
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again.  
At line:5 char:18  
+ Import-PSSession $Session  
+                  ~~~~~~~~  
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException  
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand  

Will global admin rights not give me full access on exchange online or do I also need to be part of other groups e.g. exchange admin

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-06-13T09:30:46.913+00:00

    You are using an outdated method, which is based on basic authentication, which in turn is likely blocked in your organization or made unusable by requiring MFA. Download the "V2" Exchange Online module and use the Connect-ExchangeOnline cmdlet to connect: https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.