Skip to content

Instantly share code, notes, and snippets.

@Vietwear
Forked from glombard/list-tfs-work-items.ps1
Created December 13, 2016 06:24
Show Gist options
  • Save Vietwear/bb02ca00a4a0b1abae996b31f30abe15 to your computer and use it in GitHub Desktop.
Save Vietwear/bb02ca00a4a0b1abae996b31f30abe15 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