List teams and users

From time to time, it can be handy to use the Team configuration and members in TFS to set permissions in another application.

To extract teams and the members from a collection, I’ve made this function.

Function Get-TFSUsers
Extract members and teams from TFS
Url to TFS collection
Array of TFS projects to itereate through
[string] $URL,

$TFSUsers =@()
Foreach ($Project in $Projects)
#Get Teams in project(s)
$Teams = (Invoke-RestMethod -Uri ($URL + '/_apis/projects/'+$Project +'/teams?api-version=2.2') -Method GET -UseDefaultCredentials ).value

Foreach ($Team in $Teams)
#Get Team Members
$Members = (Invoke-RestMethod -Uri ($URL + '/_apis/projects/'+$Project +'/teams/' + $ + '/Members?api-version=2.2') -Method GET -UseDefaultCredentials).value

#Create Custom object for team member
Foreach ($Member in $Members)
$props = @{
'TeamDescription' = $Team.description
'ProjectName' = $Project
$TFSUsers += New-Object -TypeName PSObject -Property $props
return $TFSUsers

This wil return an array of user objects, with team and project relationsship.

This can then be used for reporting, or to use to set permissions in other applications.



Author: KimC

TFS admin and deployment fellow

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: