Skip to main content

Posts

Showing posts from September, 2021

Register/Deregister ADO agents using PowerShell

 here is the script you can use to register/deregister ADO agents PARAM( [int] $NoofAgents, [string] $vsts_url = "https://dev.azure.com/name", [string] $vsts_pat, [string] $svcUserName = "domain\user", [string] $svcPassword, [string] $agentAction ) $agent_pool = 'Poolname'; $ErrorActionPreference="Stop"; If(-NOT (Test-Path $env:SystemDrive\'agents')) {mkdir $env:SystemDrive\'agents'}; Cd $env:SystemDrive\'agents'; if($agentAction -eq "register"){ Write-Host "Download Agent Zip from ADO..." -NoNewline $agentZip="$PWD\agent.zip"; $DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy; $securityProtocol=@(); $securityProtocol+=[Net.ServicePointManager]::SecurityProtocol; $securityProtocol+=[Net.SecurityProtocolType]::Tls12; [Net.ServicePointManager]::SecurityProtocol=$securityProtocol; $WebClient=New-Object N