Question

I'm using TFS 2012 Power Tools and PowerShell to display work items containing change sets which modified source files below a given directory within the last 120 days. With lots of good help from StackOverflow I find the work items and display them like this:

PS> $items = Get-TfsItemHistory $/Somewhere -R -All -Version "D$((Get-Date).AddDays(-120).ToString('d'))~" | select ChangesetId -ExpandProperty WorkItems | Sort-Object -Unique Id
PS> $items | format-table

This comes out looking fairly good, for example, here's the start of an output:

Id    State    AssignedTo    AreaPath            Title
--    -----    ----------    --------            -----
32604 Closed   Harald Han... Client\Domain\Nav   Change to new address space

However, if I try to show just a subset of the fields, I can't get the AssignedTo field to display. This is OK:

PS> $items | format-table AreaPath, State

AreaPath                  State
--------                  -----
KCS-Client\Domain\Nav     Closed

But this is not:

PS > $items | format-table AssignedTo, State

AssignedTo                State
----------                -----
                          Closed

I must have missed something trivial, but (as a relative newbie to both PowerShell and the TFS PowerTools) I don't see what it is. Can anybody help?

Was it helpful?

Solution

The property 'AssignedTo' is a scriptproperty evaluated at run time from the Microsoft.TeamFoundation.PowerTools.PowerShell.format.ps1xml powershell custom format file.

The value is taken from:

 $_.Fields[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreField]::AssignedTo].Value

then I think (I can't test it because I don't have a TF Server source ) you need to do:

$items | format-table @{n="AssignedTo";e={$_.Fields[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreField]::AssignedTo].Value}} , State
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top