Skip to content

Commit

Permalink
Fix: MFA STATUS Function
Browse files Browse the repository at this point in the history
  • Loading branch information
DrIOSX committed Jun 17, 2024
1 parent 5e25d6e commit 4dc996b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions source/Public/Get-MFAStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ function Get-MFAStatus {
process {
if (Get-Module MSOnline){
Connect-MsolService
Write-Host -Object "Finding Azure Active Directory Accounts..."
Write-Host "Finding Azure Active Directory Accounts..."
# Get all users, excluding guests
$Users = if ($PSBoundParameters.ContainsKey('UserId')) {
Get-MsolUser -UserPrincipalName $UserId
} else {
Get-MsolUser -All | Where-Object { $_.UserType -ne "Guest" }
}
$Report = [System.Collections.Generic.List[Object]]::new() # Create output list
Write-Host -Object "Processing" $Users.Count "accounts..."
Write-Host "Processing $($Users.Count) accounts..."
ForEach ($User in $Users) {
$MFADefaultMethod = ($User.StrongAuthenticationMethods | Where-Object { $_.IsDefault -eq "True" }).MethodType
$MFAPhoneNumber = $User.StrongAuthenticationUserDetails.PhoneNumber
Expand Down Expand Up @@ -92,12 +92,11 @@ function Get-MFAStatus {
$Report.Add($ReportLine)
}

Write-Host -Object "Processing complete."
Write-Host "Processing complete."
return $Report | Select-Object UserPrincipalName, DisplayName, MFAState, MFADefaultMethod, MFAPhoneNumber, PrimarySMTP, Aliases | Sort-Object UserPrincipalName
}
else {
Write-Host -Object "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
Write-Host "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
}
}

}
}

0 comments on commit 4dc996b

Please sign in to comment.