Connecting to both ExO and SCC using the MFA-enabled PowerShell module

There seems to be an unfortunate issue with the recently updated Exchange Online PowerShell module that brings support for Modern authentication for the Security and Compliance Center cmdlets. Namely, the script’s Connect-EXOPSSession function, used to establish the connectivity for both the ExO and SCC parts, clears out every remote session upon execution.

In effect, this means that you cannot use the module to connect to both ExO and SCC remote PowerShell sessions at the same time. Any existing sessions are simply removed upon connecting to a new one. Or illustrated with a picture:

As the Connect-IPPSSession cmdlet calls the Connect-EXOPSSession one upon execution, the order in which you connect to both will not matter. If you want to connect to both session, you will have to use separate PowerShell instances. Or, make some changes to the underlying script (edit/comment line 173).

Alternatively, you can load the necessary module functions in your scripts and bypass the execution of the Connect-EXOPSSession cmdlet. I’ve alerted the corresponding teams at Microsoft so hopefully this hiccup will get looked at soon.

This entry was posted in Exchange Online, Office 365, PowerShell. Bookmark the permalink.

2 Responses to Connecting to both ExO and SCC using the MFA-enabled PowerShell module

  1. I also figured who thought this was a good idea ..
    Get-PSSession | Remove-PSSession

Leave a Reply

Your email address will not be published. Required fields are marked *