Here's how to update the Team Foundation Registry using Powershell and the TFS client OM. Visual Studio 2010 and Team Foundation Server 2010 don't ship with a TF equivalent to regedit.exe, so you may need to use Powershell, a .Net language, a TFS Powertool or a third-party tool.

I'm not referring to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\*\TeamFoundation in the Windows Registry on client machines. The Team Foundation Registry is totally separate from the Windows Registry. The Team Foundation registry is stored across the configuration and collection databases.

 

I've made some other posts that include TF registry changes, but I'm dedicating this entry to making any change to the TF registry. To make this example as general as possible, I'll pretend I want to set the path /Configuration/ExampleService/DefaultWidgetTemplate to FabrikamWidget, delete the path /Configuration/ExampleService/MaxWidgetsPerHectometer and its associated value. I'm using these like Foo, Bar and Baz - they're stand-ins for the actual paths you're interested in modifying.

 

For a list of actual TF Registry paths and values used by the product code, see http://blogs.msdn.com/chrisid/archive/2010/05/24/list-of-tf-registry-paths.aspx

 

Updating a value in the configuration hive

 

[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

 

#Update configuration URL as necessary

$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "http://localhost:8080/tfs/"

 

# Get the configuration hive.        

$configHive = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])

 

# Browse the TF Registry Hive API.

$configHive | gm

 

# See the current settings for the ExampleService.

$configHive.ReadEntries("/Configuration/ExampleService/**") | select Path, Value | ft -a

 

# Update these settings.

$configHive.SetValue("/Configuration/ExampleService/DefaultWidgetTemplate", "FabrikamWidget")

$configHive.DeleteEntries("/Configuration/ExampleService/MaxWidgetsPerHectometer")

 

Updating a value in a collection hive

 

[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

 

#Update the team project collection URL as necessary

$projectCollection = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection "http://localhost:8080/tfs/DefaultCollection"

 

# Get the collection hive.

$collectionHive = $projectCollection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])

 

# Browse the TF Registry Hive API.

$collectionHive | gm

 

# See the current settings for the ExampleService.

$collectionHive.ReadEntries("/Configuration/ExampleService/**") | select Path, Value | ft -a

 

# Update these settings.

$collectionHive.SetValue("/Configuration/ExampleService/DefaultWidgetTemplate", "FabrikamWidget")

$collectionHive.DeleteEntries("/Configuration/ExampleService/MaxWidgetsPerHectometer")

 

Updating a value in almost every collection's hive

 

You probably don't need to do this. In a lot of the places in the TFS 2010 product code where we read a collection-level setting, we use fall-through to check the same path in the configuration hive. See my blog post TFS 2010: Faster Delivery of Notifications for example. This is equivalent to code first checking HKEY_CURRENT_USER for a setting and then HKEY_LOCAL_MACHINE before finally using whatever default shipped with the product.

 

If you really do want to modify the TF registry for almost every collection see my previous blog post, Performing the same operation against nearly every collection .