Automated Team Project Creation and Assigning User Group to Readers Group

Suppose there is a requirement to create Team projects through command line and once created, a particular User group needs to be added to one of the inbuilt user group in TFS (say Readers group).

I wrote below PowerShell script to implement it.

Requirements –

1) TFS power tools should be installed on the system.

2) Visual Studio should be installed.

Script Code –

   Script to create team project and to add user group to the Readers group
   This script will create a Team Project and will then add user’s group to the TP’s Readers group. On running the script, enter the information as asked to enter.

#Script Name – CreateTPAndAddGrptoReaders.ps1
#Creator – Mohd Aslam Ansari
#Date – 22-Dec-15
#Updated – First Version
#References, if any

$TeamCollectionURL = Read-Host "Enter Team Collection URL (Ex. https://[TFSServer/tfs/POCCollection/):"
$TeamProjName = Read-Host "Enter the Team Project Name:"
$ProcessTemplate = Read-Host "Enter the process template (Agile/CMMI/Scrum):"
$UserGroup = Read-Host "Enter the User group that needs read access with domain (Ex domain\group):"

tfpt createteamproject `
/Collection:$TeamCollectionURL `
/teamproject:$TeamProjName `
/processtemplate:$ProcessTemplate `
/sourcecontrol:New `
/Validate `

tfpt createteamproject `
/Collection:$TeamCollectionURL `
/teamproject:$TeamProjName `
/processtemplate:$ProcessTemplate `
/sourcecontrol:New `

cd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"
.\TFSSecurity.exe /g+ [$TeamProjName]\Readers n:$UserGroup /collection:$TeamCollectionURL

[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
[Microsoft.VisualBasic.Interaction]::MsgBox("Team Project created with the Name – " + $TeamProjName + ". " + $UserGroup + " added to the Readers group.","OKOnly,SystemModal,Information", "Success")


For more information on TFPT command, refer to PowerShell help by typing tfpt /?

—-End of Article—

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 )

Google+ photo

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

Connecting to %s