-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeleteXamlBuilds.ps1
26 lines (25 loc) · 1.05 KB
/
DeleteXamlBuilds.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$rootTfsUri = "http://TfsServer:8080/tfs/Projects"
$allProjectsUri = "$rootTfsUri/_apis/projects?api-version=3.1&`$top=256"
$response = Invoke-WebRequest -Uri $allProjectsUri -UseDefaultCredentials -Method Get -Verbose -UseBasicParsing
$responseObject = $response.Content | ConvertFrom-Json
if($responseObject.count -ge 1)
{
foreach($prj in $responseObject.value)
{
$project = "$($prj.name)"
Write-Verbose -Message "Deleting XAML builds for $project ..." -Verbose
# "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TFSBuild.exe delete /collection:$rootTfsUri /DateRange:~1/1/2020 $project"
$CMD = 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TFSBuild.exe'
$arg1 = 'delete'
$arg2 = "/collection:$rootTfsUri"
$arg3 = '/DateRange:~1/1/2020'
$arg4 = "$project"
& $CMD $arg1 $arg2 $arg3 $arg4
$arg1 = 'destroy'
& $CMD $arg1 $arg2 $arg3 $arg4
}
}
else
{
Write-Verbose -Message "No projects found" -Verbose
}