Deleting work items in TFS

Functionality for deleting work items in Team Foundation Server is quite successfully hidden, so many people have no idea that it is possible. (That might be even good. ;)).

TFS2010
Work items cannot be deleted from graphical interface, but it’s possible in the command line, more precisely by witadmin utility. In Visual Studio Command Prompt, you can use witadmin directly, in PowerShell, you can for example make an alias.
(I have the following command in my PowerShell profile: Set-Alias -Name witadmin -Value 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\witadmin.exe')

You can delete a work item in this way:

#In general:
witadmin destroywi /collection:[project collection URL] /id:[work item ID]
#Concrete example:
witadmin destroywi /collection:mytfs\DefaultCollection /id:42

You can specify multiple work items delimited by comma:

witadmin destroywi /collection:mytfs\DefaultCollection /id:42,44

or – let’s say – delete items in a loop:

foreach ($id in 50..100)
{
    witadmin destroywi /collection:tfs.to-increase.com\AX /id:$id /noprompt
}

To be able to delete work items, you must be a member of Team Foundation Administrators or Project Administrators user group.

TFS2008

In TFS2008 you have to resort to PowerTools and tfpt.exe destroywi command, in other respects the situation is exactly the same. For example:

tfpt.exe destroywi /server:mytfs /workitemid:42

One Comment

Comments are closed.