O365 Security & Compliance Center PowerShell (MFA)

As many admins get used to using the Security and Compliance in O365 they will find that certain tasks, like purging mail, require the use of PowerShell(POSH). Unfortunately this can be difficult if you have MultiFactor Authentication enabled(MFA), 98% of the articles I have found contain the old connection method which does not work for MFA.

The good news is that MS has released a new version of the Exchange Online Module, which contains native commands to both connect and use the Security & Compliance Center functions and supports MFA.

1. Download the new Module.

  • Log-in to O365 Admin Center
  • Select the link in the bottom left, under Admin centers, labeled Exchange
  • Click the Hybrid Link on the left panel
  • Click the Configure Button under the Exchange Online PowerShell Module, this should install the new module.
  • If You can not get the Download Module to work, check out this article Support.Microsoft.Com

2. Run the Module

  • The new Module should install to your Start Menu, simple search and run “Microsoft Exchange Online Powershell Module.

3. Connect to the Security & Compliance center

  • Run the following command:
    Connect-IPPSSession -UserPrincipalName "yourlogon"
  • At this point your MFA Pop-Up should occur and you will be prompted to continue entering credentials.

4. If you wish to now Purge any email you must first build the rules and run the search. See this article on Support.Microsoft.Com

5. And the Final Step, run the purge from the POSH Session.

  • Run the following command:
    New-ComplianceSearchAction -SearchName "The Name that you gave your Search" -Purge -PurgeType SoftDelete

Leave a Reply

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