From Azure AD, Are there any ways to find users who does not have a speciifc group assigned ( the name contain %AVD% in it) ?
This is what I have tried:
https://graph.microsoft.com/beta/users?$expand=memberOf
https://graph.microsoft.com/v1.0/users/groups?$search="AVD"
https://graph.microsoft.com/v1.0/users?$select=memberOf eq '%AVD%'
unable to get expected result. That is user principle name not a member of perticuler group which contain "AVD" in its name.
Thanks.
2
Answers
To find users who does not have a specific group assigned, please try the below PowerShell script by Marilee Turscak-MSFT:
I tried to reproduce the same in my environment like below:
Initially, I executed below command to get the users with
Jo
in their names.The user
ObjectId
"afcfad54xxxxxxxxxxx" is a member of one group like below:After executing the PowerShell script, the
ObjectId
with "f1e72629xxxxxxxxxxx" returned as it is not a member of any specified groups:Firstly, Odata
eq
doesn’t support % to execute fuzzy query, anddisplayName
property not supportcontains
function, so there’s actually no solution for graph api to return your idea result.Per my test, I think this request should work but it didn’t execute the filter actually.
https://graph.microsoft.com/v1.0/users?$expand=memberOf($select=displayName;$filter=displayName eq 'xxx';)&$select=displayName,id,memberOf
So I’m afraid you have to execute the api first and then do the filter by your code. And I wrote a sample like this: