Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED MFA report for users in a certain OU (powershell)

  • Thread starter Thread starter Markyb
  • Start date Start date
  • Replies Replies 2
  • Views Views 4K
Status
Not open for further replies.

Markyb

Member
Messages
21
Reaction score
0
Points
1
Hi all,

I'm looking for guidance on how to produce a power shell report on users that have MFA disabled in a certain OU. If tried the below and changed the OU and DC to mine, but it errors

$Users = Get-ADUser -Filter * -SearchBase 'OU=OUName,DC=Domain,DC=Com' |
Select-Object -ExpandProperty UserPrincipalName

$Results = foreach( $User in $Users ){
Get-MsolUser -UserPrincipalName $User |
Select-Object -Property UserPrincipalName, @{
Name = 'MFA State'
Expression = { $_.StrongAuthenticationRequirements.State }
}
}

$Results |
Export-Csv -Path 'C:\Temp\Report.csv' -NoTypeInformation


Any help would be appreciated.

Thanks
 
Try this :-

Code:
$Users = Get-ADUser -Filter * -SearchBase 'OU=OUName,DC=Domain,DC=Com' -Properties DisplayName

$Results = foreach( $User in $Users ){
    $MsolUser = Get-MsolUser -UserPrincipalName $User

    [pscustomobject]@{
        DisplayName       = $User.DisplayName
        UserPrincipalName = $User.UserPrincipalName
        'MFA State'       = $MsolUser.StrongAuthenticationRequirements.State
        }
    }

$Results |
    Export-Csv -Path 'C:\Temp\Report.csv' -NoTypeInformation
 
Status
Not open for further replies.

Forum statistics

Threads
7,043
Messages
27,535
Members
17,729
Latest member
ironmonkey

Trending content

Back
Top