Edit: Microsoft postponed deprecation of Exchange Online basic authentication due to COVID-19 situation. New estimated deadline is around Q2/2021.
Before there was this odd click-2-run package of modern authentication capable EXO module. I never quite got why they did it that way but I'm glad we can soon forget it completely. You can now install new Exchange Online PowerShell V2 module from the PS Gallery as it always should've been. Note that it was still in preview when writing this post.
There's really good documentation on the new module (the previous link), but let me save you a click and introduce it here briefly.
How to install
Note: All install cmdlets must be run with elevated PowerShell session (as administrator).
Install-Module -Name ExchangeOnlineManagement
You might get an error: WARNING: The specified module ... with PowerShellGetFormatVersion ‘2.0’ is not supported by
the current version of PowerShellGet. Get the latest version of the PowerShellGet module to install this module ...
If error occurs, you have to update PowerShellGet.
Install-PackageProvider -Name NuGet -Force
Exit
Install-Module -Name PowerShellGet -Force
Exit
Update-Module -Name PowerShellGet
Exit
How to use
Import-Module ExchangeOnlineManagement
$cred = Get-Credential
Connect-ExchangeOnline -Credential $cred
So, you can basically use stored credentials in your scripts and connection is made using "Modern Authentication". Azure AD sees actor as "Mobile Apps and Desktop clients" type of rich client. Actually, new EXO PS module cannot be used with basic auth at all. 
Whats new?
EXO V2 module also has a few new cmdlets, prefixed with "EXO". Old versions of these cmdlets are still there for backward compatibility.
Get-Command -Module ExchangeOnlineManagement -Noun "EXO*"
New cmdlets revealed:Get-EXOCasMailbox
Get-EXOMailbox
Get-EXOMailboxFolderPermission
Get-EXOMailboxFolderStatistics
Get-EXOMailboxPermission
Get-EXOMailboxStatistics
Get-EXOMobileDeviceStatistics
Get-EXORecipient
Get-EXORecipientPermission
New cmdlets should be more robust and therefore new V2 module introduces "property sets". You can request only properties that are relevant to your specific use case. Check available sets here.
Happy scripting and start planning modern authentication for all your scripts now!
No comments:
Post a Comment