forked from directorcia/Office365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patho365-connect-mfa-sac.ps1
33 lines (22 loc) · 1.42 KB
/
o365-connect-mfa-sac.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description - Log into the Office 365 Security and Compliance Center when multi factor security is enabled
Source - https://github.com/directorcia/Office365/blob/master/o365-connect-mfa-sac.ps1
Prerequisites = 1
1. Ensure msonline MFA module installed or updated
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
## If you have running scripts that don't have a certificate, run this command once to disable that level of security
## set-executionpolicy -executionpolicy bypass -scope currentuser -force
Clear-Host
write-host -foregroundcolor $systemmessagecolor "Script started`n"
$CompConnectionUri = "https://ps.compliance.protection.outlook.com/powershell-liveid/"
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse).FullName | ?{ $_ -notmatch "_none_" } | select -First 1)
write-host -foregroundcolor $systemmessagecolor "Exchange Online MFA module loaded"
$Comp = New-EXOPSSession -ConnectionUri $CompConnectionUri -Credential $EXOcreds
$CompImportresults = Import-PSSession $Comp -AllowClobber
write-host -foregroundcolor $processmessagecolor "Connected to Secruity and Compliance Center MFA`n"
write-host -foregroundcolor $systemmessagecolor "Script Completed`n"