Azure Devops - Deleting Workspace

前端 未结 2 1061
别跟我提以往
别跟我提以往 2020-12-21 05:34

Using Developer Command Prompt for VS 2019

I am able to see a list of all my workspaces.

tf workspaces /collection:\"https://dev.azure

相关标签:
2条回答
  • 2020-12-21 05:58

    To delete an existing workspace, you must be the owner or have the global Administer workspaces permission set to Allow.

    You could also try to use onwer uniq ID instead of name

    tf vc workspaces ws_3_3 /computer:* /format:xml /collection:https://dev.azure.com/patricklu/
    

    ws_3_3 is your workspace name which want to delete, collection just type your collection url In the prompt up window type your address to connect to the url(If there is).

    After this it will return some information such as below:

    With info of owner uniq ID

    Then you just need to use tf workspace /delete the command, in my sample it’s using:

    tf workspace /delete ws_3_3;fb46f066-9122-4342-94c4-93b7526a3545
    

    Simply type yes, it will delete the workspace. "Unable to determine the source control server" This may caused by you didn't include the collection url when you try to delete a workspace not locally.

    1. How can I delete ALL workspaces?

    There is not a command to delete all workspaces in company, you have to do it one by one.

    2. Can workspaces be deleted from the Azure Dev Ops portal?

    No, you couldn't do this. You should either use command line or through Visual Studio UI as below:

    Hope this helps.

    0 讨论(0)
  • 2020-12-21 06:19

    I recently had some issues deleting workspaces as the user who owned the workspace had left, so validation was failing to recongise their account.

    This post introduced me to the XML output from the tf workspaces command; enabling me to get the underlying id of the user and delete the workspace using that.

    Here's a PowerShell wrapper that I used to delete all workspaces for the user:

    Set-Alias -Name 'tf' -Value 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe' # amend path so it points to your tf.exe file
    
    # fetch a list of all workspaces and store them in an xml variable
    $x = [xml](tf workspaces /computer:* /owner:* /format:xml)
    
    # determine who we want to delete (this is used in our filter later; to delete all, just skip the filter
    $userToDelete = 'Someone@example.com'
    
    # for each workspace 
    # take those where the owner's display name matches our target user
    # then delete that workspace (I've left prompts enabled, so you can manually validate things; add /noprompt to avoid that
    $x.Workspaces.Workspace | ?{$_.ownerdisp -eq $userToDelete} | %{tf vc workspace /delete "$($_.name);$($_.owner)"}
    

    More info on available options in the MS Docs; so you can tweak the above per your exact requirements.

    0 讨论(0)
提交回复
热议问题