-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhoHas2FA.ps1
15 lines (11 loc) · 933 Bytes
/
WhoHas2FA.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## Connect to Echange Online
$credential = Get-Credential
Import-Module MsOnline
Connect-MsolService -Credential $credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking
## Get all users, and then check 2fa status then output to csv
Measure-Command -Expression {
Get-msoluser -All | select DisplayName,@{N='Email';E={$_.UserPrincipalName}},@{N='StrongAuthenticationRequirements';E={($_.StrongAuthenticationRequirements.State)}} | Export-Csv -NoTypeInformation C:\scripts\whohas2fa.csv
}
#Get-msoluser -All | select DisplayName,@{N='Email';E={$_.UserPrincipalName}},@{N='StrongAuthenticationRequirements';E={($_.StrongAuthenticationRequirements.State)}} | Export-Csv -NoTypeInformation C:\scripts\whohas2fa.csv