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
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