The base of this script:<\/p>\n
To find the status of all users’ MFA status in O365<\/p>\n
The issue is we have 28,000 users and I only need to get status from the users who happen to be apart of this AD group (Roughly 3000 users) but I cant seem to filter users by a certain group they belong too.<\/p>\n
Roughly the original script before filtering:<\/p>\n
##Get Users and DIsplay their MFA status & Export to CSV\nGet-MsolUser -all | select DisplayName,UserPrincipalName,@{N=\"MFA Status\"; E={ if( $_.StrongAuthenticationRequirements.State -ne $null){ $_.StrongAuthenticationRequirements.State} else { \"Disabled\"}}} | Export-CSV -Path O365MFA.csv -Force\n<\/code><\/pre>","upvoteCount":3,"answerCount":6,"datePublished":"2018-06-04T18:43:44.000Z","author":{"@type":"Person","name":"eric-schroeder","url":"https://community.spiceworks.com/u/eric-schroeder"},"acceptedAnswer":{"@type":"Answer","text":"I match them by UPN
\nYou have to adjust the “@domain.com<\/span>” do your UPN / domain name
\nThis also assumes that the samaccountname and the first UPN part match<\/p>\n$groupmembers = get-adgroupmember $YourGroupNameHEre\n$All_MSOlusers = get-msoluser -all \n\n$data = foreach($member in $groupmembers){\n $All_msolusers | where UserPrincipalName -eq \"$($member.samaccountname)@domain.com\" |\n select DisplayName,UserPrincipalName,@{N=\"MFA Status\"; E={ if( $_.StrongAuthenticationRequirements.State -ne $null){ $_.StrongAuthenticationRequirements.State} else { \"Disabled\"}}}\n}\n\n$data | Export-CSV -Path \"O365MFA.csv\" -NoTypeInformation -Force\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2018-06-04T19:28:53.000Z","url":"https://community.spiceworks.com/t/script-help-for-msonline/655193/6","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"The base of this script:<\/p>\n
To find the status of all users’ MFA status in O365<\/p>\n
The issue is we have 28,000 users and I only need to get status from the users who happen to be apart of this AD group (Roughly 3000 users) but I cant seem to filter users by a certain group they belong too.<\/p>\n
Roughly the original script before filtering:<\/p>\n
##Get Users and DIsplay their MFA status & Export to CSV\nGet-MsolUser -all | select DisplayName,UserPrincipalName,@{N=\"MFA Status\"; E={ if( $_.StrongAuthenticationRequirements.State -ne $null){ $_.StrongAuthenticationRequirements.State} else { \"Disabled\"}}} | Export-CSV -Path O365MFA.csv -Force\n<\/code><\/pre>","upvoteCount":3,"datePublished":"2018-06-04T18:43:44.000Z","url":"https://community.spiceworks.com/t/script-help-for-msonline/655193/1","author":{"@type":"Person","name":"eric-schroeder","url":"https://community.spiceworks.com/u/eric-schroeder"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>