After sharing a script to be able to upload build tasks to your on premise TFS instance, here is a second script to remove build tasks:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory=$true)][string]$TaskPath, | |
[Parameter(Mandatory=$true)][string]$TfsUrl, | |
[PSCredential]$Credential = (Get-Credential) | |
) | |
# Gather the necessary information | |
$taskDefinition = (Get-Content $taskPath\task.json) -join "`n" | ConvertFrom-Json | |
$headers = @{ "Accept" = "application/json; api-version=2.0"; "X-TFS-FedAuthRedirect" = "Suppress" } | |
$url = "$TfsUrl/_apis/distributedTask/tasks/$($taskDefinition.id)" | |
# Perform the actual request | |
Invoke-RestMethod -Uri $url -Credential $credential -Headers $headers -Method Delete |