Microsoft are (rightly) increasingly encouraging users to implement MFA in order to access Office 365. In fact, they’ve rolled out baseline conditional access polices which force this on admins and users (currently, these are disabled by default but expect it to change in the future).
So, what do you do if you want to use remote PowerShell to manage your Exchange Online service when MFA ? Well, of course you install the Exchange Online Remote PowerShell Module. This module is available as a download via the Exchange Online admin centre (click on the hybrid tab as per the below image).
Once you run the installer, it will connect to Office 365 to download the latest source files and install the module.
NOTE: I have had issues attempting to install when using Multi-account containers in Firefox, so if you do experience issues with the install, try IE or Edge.
Once the install completes you have a nice new shortcut on your desktop:
time the shortcut is run, the application verifies it is the latest version and updates itself if required, then starts PowerShell with the module loaded:
As the window says, you simply run Connect-EXOPSSession and you will be prompted for your credentials and any MFA requirements as part of authentication. This module is also used for the security and compliance services, and y!
The problem comes when you need to run the shell as an admin. Normally, we can right-click the PowerShell app and select run as administrator. Unfortunately, because it’s a shortcut on your desktop, we have no such option.
Here’s how I got around this issue:
The shortcut by default points to the install files generally located in %USERPROFILE%AppDataLocalApps2 then some variable name folders. The executable which is run is named Microsoft.Online.CSE.PSModule.Client.exe.
By pining this file to the taskbar, you can now right-click it and select run as administrator (as per the image below) and perform all those tasks which require the PowerShell shell to be run as an administrator (surely we don’t run unsigned scripts!).
One thing that you will need to be wary of is that running the executable directly via the taskbar bypasses the verification that the module is the latest version, so you will need to execute the desktop shortcut fairly regularly to make sure you are running the latest version. And if it is updated, you’ll probably find that you have go through the above again as the path to the file will have changed.
I hope this blog has provided some help to you. Let me know if you’ve found anything else out there that makes it easier to do this.