From 39a9ac8385a8b0617a8c5e77bd9817a322a6b3c3 Mon Sep 17 00:00:00 2001 From: AdminDroid <49208841+admindroid-community@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:57:48 +0530 Subject: [PATCH] Get Microsoft 365 Users' MFA Status Get Microsoft 365 Users' MFA Status --- .../GetMFAStatus.ps1 | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/Office 365 User MFA Status Report/GetMFAStatus.ps1 b/Office 365 User MFA Status Report/GetMFAStatus.ps1 index 955abe9..10d8c28 100644 --- a/Office 365 User MFA Status Report/GetMFAStatus.ps1 +++ b/Office 365 User MFA Status Report/GetMFAStatus.ps1 @@ -1,4 +1,28 @@ -Param +<# +============================================================================================= +Name: Export Office 365 MFA status report +Description: This script exports Microsoft 365 MFA status report to CSV +Version: 2.2 +website: o365reports.com + +Script Highlights: +~~~~~~~~~~~~~~~~~ + +1.The result can be filtered based on MFA status. i.e., you can filter MFA enabled users/enforced users/disabled users alone. For example using the ‘EnabledOnly‘ flag you shall export Office 365 users’ MFA enabled status to CSV file. +2.Exports result to CSV file. +3.Result can be filtered based on Admin users. +4.You can filter result to display Licensed users alone. +5.You can filter result based on SignIn Status (SignIn allowed/denied). +6.The script produces different output files based on MFA status. +7.You can use this script to get users’ MFA status set by Conditional Access. +8.The script can be executed with MFA enabled account. +9.Using the ‘Admin Roles’ column, you can find users with admin roles that are not protected with MFA. For example, you can find Global Admins without MFA. +10.The script is scheduler friendly. i.e., credentials can be passed as parameter instead of saving inside the script. + +For detailed Script execution: https://o365reports.com/2019/05/09/export-office-365-users-mfa-status-csv +============================================================================================ +#> +Param ( [Parameter(Mandatory = $false)] [switch]$DisabledOnly, @@ -191,9 +215,11 @@ Get-MsolUser -All | foreach{ #Open output file after execution Write-Host `nScript executed successfully + if((Test-Path -Path $ExportCSV) -eq "True") { - Write-Host "MFA Disabled user report available in: $ExportCSV" + Write-Host " MFA Disabled user report available in:" -NoNewline -ForegroundColor Yellow + Write-Host $ExportCSV `n $Prompt = New-Object -ComObject wscript.shell $UserInput = $Prompt.popup("Do you want to open output file?",` 0,"Open Output File",4) @@ -205,7 +231,9 @@ if((Test-Path -Path $ExportCSV) -eq "True") } elseif((Test-Path -Path $ExportCSVReport) -eq "True") { - Write-Host "MFA Enabled user report available in: $ExportCSVReport" + Write-Host "" + Write-Host " MFA Enabled user report available in:" -NoNewline -ForegroundColor Yellow + Write-Host $ExportCSVReport `n $Prompt = New-Object -ComObject wscript.shell $UserInput = $Prompt.popup("Do you want to open output file?",` 0,"Open Output File",4) @@ -213,11 +241,15 @@ elseif((Test-Path -Path $ExportCSVReport) -eq "True") { Invoke-Item "$ExportCSVReport" } - Write-Host Exported report has $PrintedUser users + Write-Host Exported report has $PrintedUser users + Write-Host `n~~ Script prepared by AdminDroid Community ~~`n -ForegroundColor Green + Write-Host "~~ Check out " -NoNewline -ForegroundColor Green; Write-Host "admindroid.com" -ForegroundColor Yellow -NoNewline; Write-Host " to get access to 1800+ Microsoft 365 reports. ~~" -ForegroundColor Green `n `n } Else { - Write-Host No user found that matches your criteria. + Write-Host No user found that matches your criteria. + Write-Host `n~~ Script prepared by AdminDroid Community ~~`n -ForegroundColor Green + Write-Host "~~ Check out " -NoNewline -ForegroundColor Green; Write-Host "admindroid.com" -ForegroundColor Yellow -NoNewline; Write-Host " to get access to 1800+ Microsoft 365 reports. ~~" -ForegroundColor Green `n `n } #Clean up session Get-PSSession | Remove-PSSession