TFS 2010: Canceling client requests
Below is an example of canceling a client request using Powershell and the client OM. In this example I have a request in mind and already know which collection it's against. While this is intended to serve as example to make you more familiar with our client OM and the Team Foundation Administration Service, I've highlighted the lines you'd want to alter to cancel a request on your system.
# Step 1: View the current requests.
[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
# Modify the TFS configuration server URL as necessary.
$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "https://localhost:8080/tfs/"
# Modify the collection URL as necessary.
$collection = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection "https://localhost:8080/tfs/DefaultCollection"
# Get the TF administration service.
$adminService = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.IAdministrationService])
# Browse the TF administration service API.
$adminService | gm
# Get the active requests for the collection of interest.
$adminService.QueryActiveRequests($collection, $true).ActiveRequests
# Step 2: Cancel a request.
# Note the id of the request you want to cancel.
$requestId = 1234
# Cancel the request.
$adminService.CancelRequest($collection.InstanceId, $requestId, "tf dir $/ /recursive is going to return millions of rows. Refine your query")