From 74a83e7444b994f159cf7214263d1b8114c954bb Mon Sep 17 00:00:00 2001 From: IxianPixel Date: Tue, 3 Sep 2024 17:25:22 +0100 Subject: [PATCH] Added Get-MFAReport --- .DS_Store | Bin 10244 -> 10244 bytes Entra/Get-MFAReport.ps1 | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Entra/Get-MFAReport.ps1 diff --git a/.DS_Store b/.DS_Store index 1206c0fdb09c2060c987049a9f0ca229cf43f864..733953d0734a78e4149f6701dff07e7a9c58db3b 100644 GIT binary patch delta 621 zcmc)HODLsr9LDkA_dk=4#h8Pa+(x8?4!Mkj%)-XFm6ZFik&YaMWGrkrympA*F(c)^ zP;$yG3vyYSS!fnEF4+hRge4nZvavfm&+=J4pB}wPFIpV4TI@+FwuoeVhT$C)YHV6d z43`#Q*tF7+3TJIgbFs72p~>5@GT^Jz6_u6v+FK-85+qAy7-51brkP=ug=g+cdEmT{aj$K7aK*c>bn^r)?u^a= delta 630 zcmc)HPe_vi9LDkI`+{vNh>dOHKtgSu($X9>!P-*r6uG&=MiiwcD7lVnqv*1t!2ZC? zM%uwkp$?UBU|oXMp;HGf=_2YuMLpIfun6B4cocT(cX;5rJs*CVNG9@T)M;yJI$d9L zDrnlPs?GP#i;l|!y|)vwf%Hu?=(%LNTwce~aHC3B$htDz_xvk+iR|*JP64$lqPY5$ z)UdM3>9uAwr=mV-L0|M$-?XH4ZD>7kcC`oknha)%UmdB9Vi@tiRxm?X~>Zz=MDk1Vpx3af1M!>BN9hTU)&2MxDT zW%$f_cWhtfxW`+La#FK;XDL5h$`!3ywx5UtI4#o=YN*A}F;37(6U`-Ch%jxmbDj&9 zFG?3zxXLxIbAv%{F+{>|8B?S!<2@eoh{p``gd8szVU(A=`s*!pSLP3!4sW51pZwRg G)9eEDhKCve diff --git a/Entra/Get-MFAReport.ps1 b/Entra/Get-MFAReport.ps1 new file mode 100644 index 0000000..18ff825 --- /dev/null +++ b/Entra/Get-MFAReport.ps1 @@ -0,0 +1,52 @@ +# Import the Microsoft Graph module +Import-Module Microsoft.Graph + +# Connect to Microsoft Graph +Connect-MgGraph -Scopes "User.Read.All", "UserAuthenticationMethod.Read.All" + +# Get all users +$users = Get-MgUser -All -Property Id, UserPrincipalName, DisplayName, AccountEnabled + +$totalUsers = $users.Count +$processCount = 0 + +# Initialize an array to store user information +$userInfo = @() + +Write-Progress -Activity "Getting User Details" -Status "Starting" -PercentComplete 0 + +foreach ($user in $users) { + $processCount++ + $percentComplete = (($processCount / $totalUsers) * 100) + Write-Progress -Activity "Getting User Details" -Status "Processing $processCount/$totalUsers - $($user.UserPrincipalName)" -PercentComplete $percentComplete + + # Get MFA methods for the user + $mfaMethods = Get-MgUserAuthenticationMethod -UserId $user.Id + + # Check if any MFA method is registered + $mfaRegistered = $mfaMethods.Count -gt 0 + + # Get user licenses + $licenses = Get-MgUserLicenseDetail -UserId $user.Id + + # Create a custom object for each user + $userObject = [PSCustomObject]@{ + UserPrincipalName = $user.UserPrincipalName + DisplayName = $user.DisplayName + AccountEnabled = $user.AccountEnabled + MFARegistered = $mfaRegistered + MFAMethods = ($mfaMethods.AdditionalProperties.'@odata.type' -join ', ').Replace('#microsoft.graph.', '') + Licenses = ($licenses.SkuPartNumber -join ', ') + } + + # Add the user object to the array + $userInfo += $userObject +} + +# Export the results to a CSV file +$userInfo | Export-Csv -Path "EntraIDUsersMFAReport.csv" -NoTypeInformation + +# Disconnect from Microsoft Graph +Disconnect-MgGraph + +Write-Host "Report generated: EntraIDUsersMFAReport.csv" \ No newline at end of file