Link to home
Start Free TrialLog in
Avatar of qvfps
qvfps

asked on

Cannot Connect to Exchange Online Using PowerShell

We have several tenants using office 365.  One of these was locked down by an employee who is no longer with the company.   I need to connect to it using PowerShell to make some changes.  

I am using an account which is a global admin and an Exchange admin.  I have tried from my computer and from a computer on the local network and whatever I have tried I get the following error message:


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:4 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 -DisableNameChecking
+                  ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand


Here are the Powershell commands I am using.  They work connecting to other tenants

$adminUPN="GlobalAdmin@myco.com"
$orgName="My Company"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type Password"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

Any suggestions would be appreciated.
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Hello there, Welcome to EE and thank you for your question.

Can you say if the user has Multi Factor Authenticator Enabled or not?

Jose

ASKER CERTIFIED SOLUTION
Avatar of Shabarinath TR
Shabarinath TR
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agree with Shabarinath.
Please login to EAC and try downloading from here.
 User generated image
Avatar of qvfps
qvfps

ASKER

Multifactor is not enabled for this tenant.   I have previously downloaded and installed the above module but I will try it again and see if it makes any difference.
Avatar of qvfps

ASKER

Thanks for the assistance.   accessing it with Connect-EXOPSSession -UserPrincipalName worked.