Question

I'm in the middle of creating a script to do large amount of moves in my TFS instance. I have the tfs cmdlets available with the 2010 TFS Power Tools, but the get-help documentation for them is very sparse. Specifically, Add-TfsPendingChange doesn't seem to support rename, which forces me to use "tf.exe rename" instead.

First off: have I somehow missed the documentation for the cmdlets? I've tried get-help on the commands, but they don't support -detailed or -examples flags. Is anything more available?

Secondly: what reason do I have to prefer any of the cmdlets over regular tf.exe? Are there benefits other than passing objects through the pipe when performing similar functions?

Was it helpful?

Solution

The TF cmdlets are a bit of a minimalistic offering at this point and that includes the provided documentation. In general I would use the TF cmdlets where they support what I'm trying to do - especially if you have any queries. Processing the output of the query cmdlets is much easier because they give you rich objects instead of the text stream you have to parse when using something like tf status . /r.

Also keep in mind that on a x64 Windows system, the TF cmdlets only work in a 32-bit PowerShell host.

OTHER TIPS

The tf cmdlets are not exactly useless, but ... we decided against trying to use them in our build environment right now, even though it means text-parsing.

Aside from the x64 thing, there are lots of missing commands (thanks @Keith) and missing parameters, and most importantly, they don't work in remote sessions!

A third option is to use the TFS public assemblies from within PowerShell. When you do this, you can access all TFS client capabilities and still use TFS cmdlets as well. Whether you choose this approach over tf.exe and the other TFS command-line executables depends on which scripting environment you prefer.

Here is a a PowerShell command to reference the TFS 2013 public assemblies (for TFS 2012 or 2010 just change Version=12.0.0.0 to Version=11.0.0.0 or Version=10.0.0.0).

'Microsoft.TeamFoundation.Client', 'Microsoft.TeamFoundation.Common', 'Microsoft.TeamFoundation.VersionControl.Client' |
    ForEach-Object {
        Add-Type -AssemblyName "$_, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    }

For your renaming example, you could then:

  1. Use the Get-TfsWorkspace cmdlet to instantiate a Microsoft.TeamFoundation.VersionControl.Client.Workspace object.
  2. Call the Workspace object's PendRename, GetPendingChanges and Checkin methods.

Something like this:

$workspace = Get-Workspace
$workspace.PendRename($oldItemPath, $newItemPath)
$pendingChange = $workspace.GetPendingChanges($oldItemPath)
$workspace.Checkin($pendingChange, $comment)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top