The latest version of Exchange Online Powershell Module, EXO V2, that we are going to use supports modern authentication and will work with MFA. So you don’t need to create an app password anymore.
Requirements for EXO V2
The new Exchange Online PowerShell module only works on PowerShell 5.x and lower. It doesn’t work on Linux or Mac. Support for PowerShell 6 and 7 is planned, but there is no release date announced yet.
You will need to configure PowerShell to run remote scripts. By default this is disabled.
- Open PowerShell in an elevated mode
Press Windows key + X and choose Windows PowerShell (admin) - Set the execution policy to Remote Signed:
You only need to set this once per computer. If haven’t set the execution policy and try to connect to Exchange Online you will get an error:
Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.
Install the Exchange Online V2 Module in PowerShell
We need to install the EXO V2 Module in PowerShell before we can connect to Exchange Online. Again open an Elevated Windows PowerShell window:
- Open PowerShell in an elevated mode
Press Windows key + X and choose Windows PowerShell (admin) - Install PowerShellGet
We need to install PowerShellGet before we can install the EXO V2 Module.
- Install EXO V2 module
We can now install the latest Exchange Online PowerShell module with the Install-Module cmdlet
Automatically check if EXO Module is installed
Are you going to use the Exchange Online module in a script? Then make sure you automatically check if the module is installed before your try to connect.
With the use of a single cmdlet, we can list all installed modules in PowerShell. You can prevent unnecessary errors by simply verifying that the ExchangeOnlineManagement module is available.
The cmd above should return a list of installed Exchange Online modules. If the result is empty, then we know that the module isn’t installed.
Connect to Exchange Online with PowerShell
With the Exchange Online Module installed we can now easily connect to Exchange Online with a single cmd in PowerShell:
$name = Read-Host ‘For which user are you requesting calendar data?‘
Get-MailboxFolderPermission -Identity ${name}:\agenda
Get-MailboxFolderPermission -Identity ${name}:\calendar
calenderprocessing
Get-CalendarProcessing -Identity “name.of.the.room.or.agenda” | Format-List