3

Is there a way to search TFS using PowerShell to find all changesets that contain some sub-string in the check-in comment? I'd like to see the individual files in all the changesets in one view. In my case I am searching for all changesets that contain a defect number e.g. 'D-12345'.

I tried the example as outlined here. But running ...

tf history $/MyCodeRepo/Trunk -r /noprompt /format:detailed | ? { $_.comment -like *D-12345* }

... gives me several errors:

  • You must provide a value expression on the right-hand side of the '-like' operator.
  • You must provide a value expression on the right-hand side of the '*' operator.
  • Unexpected token 'D-12345*' in expression or statement.

I then tried putting quotes around the search string but that just returned no results.

I have TFS power tools installed and I know you can use searchcs to search by Comment but you have to open each changeset individually.

Any ideas how I can do this?

Thanks,

Community
  • 1
  • 1
Gavin Sutherland
  • 1,666
  • 3
  • 23
  • 36
  • Does it have to be command line? I can knock something up using the API in Linqpad in about 2 minutes :) – DaveShaw Aug 19 '13 at 16:56
  • Dumb question, but you *are* running that command in PowerShell, not from a normal command prompt? – Edward Thomson Aug 19 '13 at 17:25
  • Have you tried using the tfs snapins that come with the powertools? – Mike Cheel Aug 19 '13 at 17:59
  • Hi @Mike, no I haven't. I'm not familiar with TFS snapins. How would I go about using them? What can they be used for? Thanks – Gavin Sutherland Aug 19 '13 at 19:22
  • The snap-ins come with the tfs power tools (i'm familiar with 2010 version). You must run them from an x86 prompt. Do a Add-PSSnapin Microsoft.TeamFoundation.PowerShell to add it. There is a Powershell entry in the power tools programs folder (in start menu). And you can do a lot of the things that tf.exe can do like query history. – Mike Cheel Aug 19 '13 at 19:34

1 Answers1

2

Try with

tf history $/ -r | ? { $_.comment -like *D-12345* }

You can also try with fpt searchcs

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51