Forum Discussion
Can I Connect to O365 Security & Compliance center via powershell with MFA on?
- May 10, 2017
Nope, not yet. It's the last of the "modules" I use to get MFA support :(
If you launch it from the "Microsoft Exchange Online Powershell Module" it works great...
But if you do lots of PS administration of O365, it's horrible to have to launch a separate window just for this. I need to be able to have it import the commandlets from these modules into other PS consoles.
I found how to do the Exchange side (link below), but cannot figure out how to do the same for the Compliance Center.
Here is the short version for Exchange MFA...
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1)
$EXOSession = New-ExoPSSession
Import-PSSession $EXOSessionhttps://github.com/Scine/Powershell/blob/master/Connect%20To%20Powershell%20with%20or%20without%202%20form%20factor%20auth%20enabled
Any ideas on how to do the same for Compliance Center?
It uses the same module and the same cmdlet, just differnt parameters. Simply open the CreateExoPSSession.ps1 from the install dir, and you will see it.
New-EXOPSSession -ConnectionUri 'https://ps.compliance.protection.outlook.com/PowerShell-LiveId'
- Shawn SaucierSep 07, 2017Copper Contributor
Awesome. That does it, which means we now have parity between PS with and without MFA!
So to connect ONLY to the CC using MFA, it looks like this:
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1) $MFCCPSSession = New-ExoPSSession -ConnectionUri 'https://ps.compliance.protection.outlook.com/PowerShell-LiveId' import-pssession $MFCCPSSessionAlso note: Here is a MS Gallery script to connect to all the O365 components with MFA. It currently doesn't include the Compliance Center, but I suspect it will soon!
Thanks Vasil!
-Shawn
https://gallery.technet.microsoft.com/Office-365-Connection-47e03052
- VasilMichevSep 07, 2017MVP
Just FYI, the deployment seems to have finallized across all datacenters/regions. The issues I had with connecting have disappeared now, and I can access the SCC cmdlets with the MFA module just fine, across all tenants.
- m kSep 19, 2017Copper Contributor
Through some trial and error, I have discovered that the below script allows me to connect to Security & Compliance Center. This is modified fromt he original located at https://support.office.com/en-us/article/Search-for-and-delete-email-messages-in-your-Office-365-organization-Admin-Help-3526fd06-b45f-445b-aed4-5ebd37b3762a
I also got the idea from you. :)
$UserCredential = Get-Credential
$Session = New-EXOPSSession -ConnectionUri 'https://ps.compliance.protection.outlook.com/powershell-liveid'
Import-PSSession $Session -AllowClobber -DisableNameChecking
$Host.UI.RawUI.WindowTitle = $UserCredential.UserName + " (Office 365 Security & Compliance Center)"