Managing Visual Studio/TFS Workspaces at the Command-Line

List current workspaces for your user:

C:\temp>tf workspaces /collection:tfs.hostname/tfs/ /login:\, Collection: http://tfs.hostname/tfs
Workspace Owner Computer Comment
------------ ------------ --------- -------------------------------------------------------------
CODE1 Dustin Oprea DUSTIN-PC

Map a new one locally:

C:\temp>mkdir test-workspace
C:\temp>cd test-workspace
C:\temp\test-workspace>tf workspace /new /noprompt test-workspace /collection:<TFS URL PREFIX>/<COLLECTION NAME> /login:<DOMAIN>\<USERNAME>,<PASSWORD> 
C:\temp\test-workspace>tf workfold /map "$/<PROJECT NAME>" test-workspace

Populate it:

C:\temp\test-workspace>tf get "$/<PROJECT NAME>" /Recursive

If you want to dispose of it, then, first, unmap it:

C:\temp\test-workspace>cd ..
C:\temp>tf workfold /unmap test-workspace /workspace:test-workspace /login:<DOMAIN>\<USERNAME>,<PASSWORD>
C:\temp>tf workspace /delete /noprompt test-workspace

Now, recursively delete the workspace directory.

“Unable to create the workspace ” due to a mapping conflict.”

This is a natural extension of the above:

If you’d like to list workspaces pass the TFS user as the owner:

C:\>tf workspaces /computer:<COMPUTER NAME> /collection:<TFS URL PREFIX>/<COLLECTION NAME> /owner:<OWNER NAME>
Workspace        Owner               Computer   Comment
---------------- ------------------- ---------- --------------------------------------------------------------------------------------
<WORKSPACE NAME> <OWNER NAME> <COMPUTER NAME> Workspace Created by Team Build

Delete the workspace mentioned in the error or found via the listing:

C:\>tf workspace /delete /collection:<TFS URL PREFIX>/<COLLECTION NAME> <WORKSPACE NAME>;<OWNER NAME>