How to add users to team foundation server 2008 using TFS SDK? I want to add these users to the contributors group of 1 of my team projects.
A:
I think does what you need (untested):
# add me to the Contributors security group on MyTeamProject
$tfs = Get-TfsServer njtfs -all
$user = $tfs.gss.ReadIdentityFromSource($tfs.GSS_SearchFactor::AccountName, "rberg")
$uri = $tfs.css.GetProjectFromName("MyTeamProject").uri
$role = $tfs.gss.ListApplicationGroups($uri) | ? { $_.displayname -match "Contributors" }
$tfs.gss.AddMemberToApplicationGroup($role.Sid, $user.Sid)
Translating to C# or other .Net languages should be simple.
Richard Berg
2009-11-09 17:30:11