Reporting on TFS Work Item Statuses

I recently had a need to regularly get an update on the numbers of TFS work items at various statuses within a particular sprint. Here’s a powershell script that will query TFS an give you back the nubmers:

param (
    [string]$project = $(throw "Parameter '-project' is required."),
    [int]$sprint = $(throw "Parameter '-sprint' is required.")
$query = "select System.State from WorkItems where System.TeamProject = '" + $project + "' and Conchango.VSTS.Scrum.SprintNumber = " + $sprint
push-location C:MyTFSWorkspaceFolder
[xml]$sprintitems = tfpt query /wiql:$query /format:xml
$sprintitems.selectnodes("WorkItems/WorkItem/Fields/Field[@RefName='System.State']/@Value") | group Value | format-table Name,Count

You’ll need the TFS Power Tools installed. Plus, you’ll notice that we have the Conchango Scrum template installed in TFS.