Tuesday 28 November 2017

PS Script Get All Team Projects Listed as HTML–TFS/VSTS

You may want to sometimes satisfy the needs of your team, specially PMs, requesting already available information in document format. Some managers are lazy to go and explore (that's why they choose to be managers not techies) and they sometimes expect information to be delivered to their hands Smile. List of Team projects in each collection can easily be seen on the TFS web interface or in VSTS in admin mode. But here is a PowerShell script to generate the same list as HTML file with link to the relevant team project, if someone requested you to have it as a separate document.


To execute this PowerShell in VSTS or TFS 2017 or 2018 you can create a Persona Access Token (PAT) with all scopes (all scopes required here to enable access to collection level information). You can call the script with you VSTS account as shown below.

.\GetAllProjects.ps1 -tfsUri 'https://youraccount.visualstudio.com' -token 'xxxxxxxxPATxxxxxxxxxxxxxx'

To call the script for TFS on premise 2017, 2018 you can use either of below depending on your TFS is setup with SSL.

.\GetAllProjects.ps1 -tfsUri 'https://yourtfs/tfs' -token 'xxxxxxxxPATxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

or

.\GetAllProjects.ps1 -tfsUri 'http://yourtfs:8080/tfs' -token 'xxxxxxxxPATxxxxxxxxxxxxxxxxxxxxxxxxxxx'image

If you are using the TFS 2015 then modify the script as shown below to enable username password authentication as there is no PAT support. Instead of PAT user name password should be taken as parameters and credential object created instead of header.image

Change the invoke rest methods to use the credential object instead of header.image

Then you can call the script in the following format.

.\GetAllProjects.ps1 -tfsUri 'https://yourtfs/tfs' -User 'yourdomain\username' -Password 'password'

The report generated in html format can be opened in any browser.image

No comments:

Popular Posts