Skip to content

Instantly share code, notes, and snippets.

@v2keener
Created March 4, 2014 14:10
Show Gist options
  • Save v2keener/9347116 to your computer and use it in GitHub Desktop.
Save v2keener/9347116 to your computer and use it in GitHub Desktop.
Retrieve Work Hours from TFS with PowerShell
<#
Taken from Julian Kay's Blog
http://juliankay.com/development/querying-tfs-with-tfpt-exe-and-powershell/
#>
Function Get-WorkItemHours
{
$month = (Get-Date).ToString("MMMM")
$year = (Get-Date).Year
$query = "SELECT [Completed Work] FROM WorkItems " +
"WHERE [System.AssignedTo] = 'Julian Kay' " +
"AND [Assigned Month] = '$month' " +
"AND [Assigned Year] = '$year'"
$hours = tfpt query /collection:$TFSSERVER /wiql:$query /include:data
$total = 0.0
foreach ($hour in $hours)
{
$total += $hour
}
$total
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment