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!

PENDING MFA report for users in a certain OU and exclude some OU's (powershell)

  • Thread starter Thread starter Markyb
  • Start date Start date
  • Replies Replies 2
  • Views Views 2K

Markyb

Member
Messages
21
Reaction score
0
Points
1
Hi Prajwal,

You recently gave me this code for a MFA report, which worked really well. Now I'd like to exclude certain OU's from the script. I've tried a few suggestions from Google but none of them work.

Any help would be really appreciated.

Thanks
Mark

$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
 

Forum statistics

Threads
7,043
Messages
27,535
Members
17,730
Latest member
betablocka

Trending content

Back
Top