Last active
April 17, 2019 17:08
-
-
Save TravisEz13/a62cc109476176a97d182b6146694bf3 to your computer and use it in GitHub Desktop.
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)] | |
[string]$Url, | |
[parameter(Mandatory)] | |
[string]$Pat, | |
[parameter(Mandatory)] | |
[string]$Pool | |
) | |
$ErrorActionPreference = 'stop' | |
$agentZipUrl = 'https://vstsagentpackage.azureedge.net/agent/2.148.2/vsts-agent-win-x64-2.148.2.zip' | |
$installPsUrl = 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1' | |
Invoke-WebRequest -Uri $installPsUrl -outFile ./install-powershell.ps1 | |
./install-powershell.ps1 -AddToPath | |
Invoke-WebRequest -Uri $agentZipUrl -outFile ./agent.zip | |
Expand-Archive -Path ./agent.zip -DestinationPath C:\AzDevOpsAgent -force | |
$workDir = 'C:\1' | |
$null = New-Item -ItemType Directory -Path $workDir | |
Write-Host "Url: $Url" | |
Write-Host "Pool: $pool" | |
C:\AzDevOpsAgent\config.cmd --unattended --url $Url --auth pat --token $Pat --pool $Pool --agent $env:Computername --work $workDir --runAsService |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line # 21 should be changed to the following as
Expand-Archive
is not supported on Windows PowerShell version below 5.0.