PSDevOps icon indicating copy to clipboard operation
PSDevOps copied to clipboard

get-adoteam doesn't return full list of teams

Open JJKW1984 opened this issue 2 years ago • 6 comments

It appears this command doesn't get all teams available in the organization which is a different API. https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-all-teams?view=azure-devops-rest-7.0&tabs=HTTP

It also only lists a small group of teams inside a specific project, and I don't see a way to indicate top or skip params: https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-teams?view=azure-devops-rest-7.0&tabs=HTTP

JJKW1984 avatar Jan 16 '23 17:01 JJKW1984

@StartAutomating Do you if this is me doing something wrong or if it is a real bug?

JJKW1984 avatar Jan 20 '23 18:01 JJKW1984

@JJKW1984 It's neither. It's just that Azure DevOps is a bit of a punk when it comes to API naming.

Teams are a concept that is truly locked down to a specific, well, team.

All Teams are implicitly users in their own right.

So you can see all of the users and teams throughout an org with Get-ADOUser, not Get-ADOTeam, because that's what the underlying apis support.

Get-ADOUser -Organization $myOrg should give you all of the users.

I'm sorry this part of Azure DevOps is so wonky.

It took me a while to figure out, too.

Let me know if you need any more help.

StartAutomating avatar Jan 21 '23 22:01 StartAutomating

@StartAutomating That is strange. I agree the DevOps API is wonky. You made a good point in your last video - Microsoft should use openapi. But alas, company priorities. I'm still trying to learn this code base and match our implementation to this much better version. Thanks for all your work!

I think teams as part of the core API has its own end points: https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams?view=azure-devops-rest-5.1

When I use get-ADOTeams and it indeed returns what would be expected but hits a max return size.

When I wrote a part of our internal VSTSLibrary and I ended up using this sloppy solution: https://dev.azure.com/$org/_apis/teams?$top=5000 which returns all the teams vs the normal return which is think is something like 200.

Ref: https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-all-teams?view=azure-devops-rest-5.1&tabs=HTTP

I don't see how to grab all teams via Get-ADOUser.

JJKW1984 avatar Jan 22 '23 04:01 JJKW1984

Ah.

It does look like that API is covered.

It appears to be the default parameter set of Get-ADOTeam.

I wonder, are you using Connect-ADO with a -Project?

StartAutomating avatar Jan 23 '23 00:01 StartAutomating

I couldn't find a call the core teams api just the projects/api. What line number is that in get-adoteams?

I don't see a -project parm on the connect-ado command.

I am doing: connect-ADO -Organization $org -PersonalAccessToken (Get-Content .\pat.txt) `$teams = Get-ADOTeam' This which returns all the correct data but only the first 100 of the 3500 or so teams.

JJKW1984 avatar Jan 23 '23 02:01 JJKW1984

Hmm.

This may be a pagination issue then. This is another thing Azure DevOps does inconsistently.

Could you try using Invoke-ADORestApi to call the api directly (providing $top=100&$skip=0)?

StartAutomating avatar Jan 23 '23 20:01 StartAutomating