DistributedTasks/Get-AzureDevOpsAgentPools.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function Get-AzureDevOpsAgentPools {
    param (
        [string]$organizationUri,
        [string]$vstsToken        
    )
    Process {
        $headers  = @{ "Authorization" = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("vsts:$vstsToken")))"; }
        $uri      = "$organizationUri/_apis/distributedtask/pools?api-version=5.1"

        Write-Host "Get agent-pools from '$organizationUri'" -f Gray
        return ((Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing).Content | ConvertFrom-Json).value
    }
}
#Set-Alias -Name Get-AzureDevOpsAgentPools -Value Get-DevOpsAgentPools
Export-ModuleMember -Function Get-AzureDevOpsAgentPools #-Alias Get-DevOpsAgentPools