Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TFS PowerShell to get list of changesets and associated work items?

Tags:

powershell

tfs

I'm a novice with the PowerShell and TFS cmdlets and I'm trying to retrieve a list of changesets in an area path, and their associated work items.

I've got as far as listing changesets since a certain date:

Get-TfsItemHistory "$/Project/Branch" -Version “D01/12/10~” -Recurse 

and also listing workitems since the same date:

Get-TfsItemHistory "$/Project/Branch" -Version "D01/12/10~" -Recurse | %{ $_.workitems }

Each query returns the same number of results, with the second query returning duplicate workitems. This seems promising, as there are many changesets to workitems, so I assume I'm not far off combining the results.

like image 862
DaBozUK Avatar asked Dec 15 '10 17:12

DaBozUK


2 Answers

Yes, you're on the right track. Try this as a way to view workitems associated with a changeset:

Get-TfsItemHistory "$/Project/Branch" -Version "D01/12/10~" -Recurse | 
    Select ChangesetId -exp WorkItems | 
    Format-Table Id,Title -GroupBy ChangesetId -Auto
like image 154
Keith Hill Avatar answered Oct 05 '22 01:10

Keith Hill


Using Microsoft.TeamFoundation.Client view https://stackoverflow.com/a/30047077/4051367

Usage

$versionControlServer.QueryHistory

$vCSChangeSets = $versionControlServer.QueryHistory($locationToSearch, $latest, 0, $recursionType, $userName, $versionFrom, $versionTo, [int32]::MaxValue, $true ,$false, $false, $true) 
$TargetChangeSetChangeItems = @()  


$TargetChangeSetChangeItems = foreach ($vCSChangeSet in $vCSChangeSets) 
{   
    foreach ($vCSChange in $vCSChangeSet.Changes) 
    { 
        $vCSItem =  $vCSChange.Item 

        # MORE CODE HERE, OMMITTED
    }
}
like image 22
PreguntonCojoneroCabrón Avatar answered Oct 05 '22 03:10

PreguntonCojoneroCabrón