TFS 2017 Removing orphaned workspace with pending changes

By Mirek on (tags: TF, TFS 2017, categories: tools, infrastructure)

After we migrated our TFS 2010 installation to latest TFS 2017 it turned out that there are some conflicts with the workspaces. Here is a simple solution how to handle such problems.

The conflicts was mostly due to the facts that together with TFS migration we also created new account for all contributors. Old accounts were abandoned but the glorious TFS version control still hold a references to it. Somehow it remembered the old workspaces and a list of pending changes on them. Yes, I know that should be handled before the migration, but for some reasons was not detected and missed.

Anyway the solution turned out to be quite straight forward with use of the TF Command line Utility. This utility can be found under the Visual Studio 2017 installation at

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe

and is able to manage workspaces, items lock, branches and many many more.
We are interested in the command called workspace and its ability to delete the workspace.

All we need to know is

  1. The TFS team project collection url ex. http://tfs.company.net/DefaultCollection/
  2. The name of the orphaned workspace together with the name of the orphaned account. You can find that details on an error message in Visual Studio when you try to check out any changes on locked item. ex. simple.project;OLDDOMAIN\user.name
  3. The login and password for the valid account on TFS which has sufficient permissions to handle workspaces ex. NEWDOMAIN\myself.name

Then we open a command line and type in following

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" workspace /delete /collection:"http://tfs.company.net/DefaultCollection/" "simple.project;OLDDOMAIN\user.name" /login:"NEWDOMAIN\myself.name",password

The tool will ask if we are sure to remove the workspace and after accepting it the orphaned workspace registration will be removed from the TFS server.