It’s officially documented on this page (you should start there)
The only thing missing on this page is what happens if you’re behind a proxy.
After the first use, you have an .appref-ms file sitting on your desktop that points to the URL below.
To get it right the first time, immediately, here are the basic steps
# Launch a new shell
# type the following in this new shell
$o = New-PSSessionOption -ProxyAccessType IEConfig
Connect-EXOPSSession -UserPrincipalName `
"firstname.lastname@example.org" -PSSessionOption $o
The first visit to the URL above will download Microsoft.Online.CSE.PSModule.Client.exe somewhere under ~/AppData\Local\Apps\2.0\
If you don’t have an application whitelisting solution blocking it, you’ll see
Once executed, it will download whatever dependencies are required (System.Management.Automation.dll, Microsoft.IdentityModel.Clients.ActiveDirectory.dll, Microsoft.Exchange.Management.ExoPowershellModule.dll, Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll,…) and run the downloaded CreateExoPSSession.ps1 script that will display this new shell
# it runs this actually to start a new shell
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoExit -ExecutionPolicy RemoteSigned -File ~\AppData\Local\Apps\2.0\YO2PKAE1.DKY\GAOJE34E.RXK\micr..tion_1975b8453054a2b5_0010.0000_22e56f9efbc200c6\CreateExoPSSession.ps1
Then you can capture the proxy settings defined in your profile and use them when you need to connect to the remote endpoint that allows you to manage the remote Exchange online infrastructure.
The Connect-EXOPSSession function should be used with a UserPrincipalName parameter and not credentials. The UserPrincipalName allows you to get the MFA form while the credentials assume that you don’t have MFA enabled. If you use credentials instead of the UserPrincipalName, you get an error saying that you’ve MFA enabled and you didn’t go through the MFA validation process:
New-ExoPSSession : AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access ‘00000002-0000-0ff1-ce00-000000000000’.
Enjoy EXO with MFA 😎