-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ps1
41 lines (34 loc) · 1.01 KB
/
setup.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
***** Description *****
Sets up VSTS agents in bulk
***** Example *****
.\setup.ps1 -pat "xxxxx" -url "https://xxxx.visualstudio.com" `
-agentSourcePath "vsts-agent-win-x64-2.129.1.zip" -targetPathRoot "e:\vsts" `
-copies 1 -agentPrefix "my-test-bd-agent" -pool "MyTestPool"
Note : Needs to run with Administrator rights.
#>
Param(
[string]$pat,
[string]$url,
[string]$agentPrefix,
[string]$pool,
[string]$agentSourcePath,
[string]$targetPathRoot,
[int]$copies
)
foreach($n in 1..$copies)
{
if($copies -eq 1)
{
$agentName = "$agentPrefix"
} else {
$agentName = "$agentPrefix-$n"
}
$tgtDir = "$targetPathRoot\$pool\$agentName"
Expand-Archive -Path $agentSourcePath -DestinationPath $tgtDir
Write-Host "Setting up $agentName"
$cmd = "$tgtDir\config.cmd"
$arg = "--unattended --url $url --auth pat --token $pat --runAsService --pool $pool --agent $agentName"
$fullCmd = "$cmd $arg"
Invoke-Expression $fullCmd
}