When trying to connect to Exchange Online PowerShell using the code below with a global administrator account, I was getting an access denied error:
$usercredential = get-credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri<span class="Apple-converted-space"> </span>https://outlook.office3 65.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : [ClientAccessServer=VI1PR08CA0018,BackEndServer=,RequestId=1c6b263f-08cf-4885-937c-e9c9808ddf89,TimeStamp=1/12/2017 2:46:41 PM] Access Denied For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:12 + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin gTransportException + FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed
I was able to succesfully logon to https://login.microsoftonline.com/ so the credentials were correct.
Also I had not enabled Multi-factor authentication because I knew this could be a problem.
I tried clearing credentials / cookies in browsers and credential manager.
Since this did not solve the issue, I started to search online for answers. The first result was : https://support.microsoft.com/en-gb/kb/2905767 which suggested I entered the wrong username/password or that I didn’t have the correct permissions (organization administrator).
Both where not the case.
I then came across this post where someone apparently had to reset the password: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin-mso_manage/exchange-online-remote-powershell-access-denied/b91205bf-3419-4251-badc-4181af701d4f , but this was also not the case for me.
So I tried using the new Exchange Online PowerShell module that supports Azure multi-factor authentication (MFA) and the Connect-EXOPSSession cmdlet which did seem to work.
As it turns out, I accidentally tried to logon using <domain>\username instead of using my User Principal Name (UPN). When using my UPN it worked perfectly.
As a bonus though, now I have no excuse anymore to start testing with MFA
For more information about the new Exchange Online PowerShell module that supports Azure multi-factor authentication (MFA) see: https://technet.microsoft.com/en-US/library/ms.exch.eac.EXORPSMFAModuleLearnMore(EXCHG.150).aspx?v=15.1.860.4&l=1&s=BPOS_S_E15_0