How to remove TFS workspace mapping for a user

Introduction

In this article, you will know how to remove TFS workspace mapping for a different user. In a remote environment, multiple users log in to a remote machine and create their workspaces that cause an access conflict for the mapped workspace folder.

Scenario

Today I faced an issue while trying to update a mapped TFS workspace in Visual Studio 2017. Visual Studio stops responding if I try to open “Source Control Explorer” and found that some different TFS user connects to TFS and mapped some folders on my local drive. Now I need to access that mapped workspace folder because I do not want to create another folder for myself.

I tried mapping same remote folder to my existing local folder and I got the following error:

“The working folder ‘Workspace_Folder_Local_Path’ is already in use by the workspace WORKSPACE_NAME:USER_NAME on computer ‘MACHINE_NAME’”


Remove TFS workspace user mapping

Prerequisites:
  • You should have administrative rights to the collection.
  • TF command. ( it is located at “C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE” depend upon your Visual Studio version.

Steps to remove user workspace mapping
  • Run “Developer Command Prompt for VS 2017” from the Start menu.
  • List the workspaces associated with the user using the below command:
      TF workspaces /collection:"http://tfsserver:8080/tfs/collection_name" /owner:owner_id
    

    This will return the list of workspaces owned by the user and computer they are associated with. For owner_id, you use the user name e.g. Niranjan Singh

  • To remove user workspace mapping, run the below command:
      tf workspace /delete workspacename;owner_id 
    

    Now it will confirm you to delete the user mapping. Enter 'y' to initiate the process.

    Remove TFS Workspace Mapping for a user

Conclusion

These are the steps to delete the TFS workspace mapping for a user.