Skip to content

Instantly share code, notes, and snippets.

@glombard
Created April 28, 2014 13:57
Show Gist options
  • Save glombard/11372920 to your computer and use it in GitHub Desktop.
Save glombard/11372920 to your computer and use it in GitHub Desktop.
Access TFS API using PowerShell
@(
'Microsoft.TeamFoundation.Build.Client',
'Microsoft.TeamFoundation.Build.Common',
'Microsoft.TeamFoundation.Client',
'Microsoft.TeamFoundation.WorkItemTracking.Client'
) | % {
[Reflection.Assembly]::LoadWithPartialName($_) | Out-Null
}
$uri = [URI]"https://my-tfs-online.visualstudio.com/DefaultCollection/"
$projectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($uri)
$wis = $projectCollection.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
$col = $wis.Query(@"
Select [State], [Title]
From WorkItems
Where [System.TeamProject] = 'My Project'
Order By [State] Asc, [Changed Date] Desc
"@)
$col | Format-Table -Property Id, State, Title -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment