How to access "Custom" or non-System TFS workitem fields using PowerShell?

Posted by DaBozUK on Stack Overflow See other posts from Stack Overflow or by DaBozUK
Published on 2010-12-16T17:50:51Z Indexed on 2010/12/23 9:54 UTC
Read the original article Hit count: 313

Filed under:
|
|

When using PowerShell to extract information from TFS, I find that I can get at the standard fields but not "Custom" fields. I'm not sure custom is the correct term, but for example if I look at the Process Editor in VS2008 and edit the Work Item type, there are fields such as listed below, with Name, Type and RefName:

Title         String    System.Title
State         String    System.State
Rev           Integer   System.Rev
Changed By    String    System.ChangedBy

I can access these with Get-TfsItemHistory:

Get-TfsItemHistory "$/path" -Version "D01/12/10~" -R 
  | Select -exp WorkItems | Format-Table Title, State, Rev, ChangedBy -Auto

So far so good.

However, there are also some other fields in the WorkItem type, which I'm calling "Custom" or non-System fields, e.g.:

Activated By  String    Microsoft.VSTS.Common.ActivatedBy
Resolved By   String    Microsoft.VSTS.Common.ResolvedBy

And the following command does not retrieve the data, just spaces.

Get-TfsItemHistory "$/path" -Version "D01/12/10~" -R 
  | Select -exp WorkItems | Format-Table ActivatedBy, ResolvedBy -Auto

I've also tried the names in quotes, the fully qualified refname, but no luck. How do you access these "non-System" fields?

Thanks

Boz

UPDATE:

From Keith's answer I can get the fields I need:

Get-TfsItemHistory "$/Hermes/Main" -Version "D01/12/10~" -Recurse `
  | Select ChangeSetId, Comment -exp WorkItems `
  | Select ChangeSetId, Comment, @{n='WI-Id'; e={$_.Id}}, Title -exp Fields `
  | Where {$_.ReferenceName -eq 'Microsoft.VSTS.Common.ResolvedBy'} `
  | Format-Table ChangesetId, Comment, WI-Id, Title, @{n='Resolved By'; e={$_.Value}} -Auto

© Stack Overflow or respective owner

Related posts about powershell

Related posts about tfs