1
votes

Trying to get a list of Teams a specific user has ownership with Graph api.

Any assistance is much appreciated.

This command will provide a list of teams but you need to get the group id first: https://graph.microsoft.com/beta/groups/{id}/owners

I tried the following but I couldn't get the correct results. https://graph.microsoft.com/beta/groups?$expand=owners($filter=userprinciplename eq '<>'&$select=id,displayname,userprinciplename)&$filter=resourceProvisioningOptions/Any(x:x eq 'Team')

2

2 Answers

2
votes

You can use ownedObjects to get the list of directory objects that are owned by the user. This includes Unified Groups in the groupTypes and output the resourceProvisioningOptions here too.

https://graph.microsoft.com/v1.0/me/ownedObjects

more documentation on that here https://docs.microsoft.com/en-us/graph/api/user-list-ownedobjects?view=graph-rest-1.0&tabs=cs .

Unfortunately it is not supported to use $filter like this. So you'll have to do on your side. So this won't work

https://graph.microsoft.com/v1.0/me/ownedObjects?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')
-1
votes

Your query was incorrect. Please try the below updated query.

https://graph.microsoft.com/beta/groups?$expand=owners($filter=userprinciplename eq 'add your mail id here')&select=id,displayname&$filter=resourceProvisioningOptions/Any(x:x eq 'Team')