2020-05-30

IT/TECH: Exchange Online (O365) & PowerShell: Access denied and other stupid failures... or how-to use Exchange Online Powershell V2 module without IE

THIS IS GOING TO BE REVIEWED and written more in detail as soon as I find some time, however, it may be of any help until than - and if it is just that I remember where to go ;)

If you, like me, fighting some Microsoft decisions when it comes to using an on-premise domain and integrate it afterwards you decided to just go with Azure-AD / Office 365 without on-premise, you will sooner or later come to a point where you potentially need to access Exchange Online with PowerShell.

If you, like me, also decided to get rid of IE wherever possible, you will figure out that you get Access Denied errors and other, strange issues when accessing O365 Exchange from PowerShell.

Sooner or later you'll realize that opening Office 365 Exchange Admin Center (https://portal.office.com -> Admin -> Exchange Admin Center) and here clicking on Hybrid -> and than configure below the Exchange Online PowerShell Module the next problem arises: No Internet Explorer, no success. You cannot install the module without IE successful - at least not according to all right now existing documentation if you search the way I did.

So either you open the module via IE which might work directly on a non-core-Windows server but is not really feasible or you'll find the following page https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2?view=exchange-ps and here we go: Install and maintain the Exchange Online PowerShell V2 module.

If you are following https://docs.microsoft.com/en-us/office365/troubleshoot/active-directory/duplicate-attributes-prevent-dirsync to fix your current issues, you just need to adopt the commands to the current ones.

You also may want to consult https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps if you are using MFA to get the session from the ladder link working.

a) Connect-EXOPSSession -UserPrincipalName chris@contoso.com -DelegatedOrganization fabrikam.onmicrosoft.com 
b) $SessionExO = GetPSSession
c) Import-PSSession $sessionExO -prefix:Cloud

and than you can go on.