Skip to main content

Get-VSTeamAgent

SYNOPSIS

Returns the agents in a pool.

SYNTAX

List (Default)

Get-VSTeamAgent -PoolId <Int32> [<CommonParameters>]

ByID

Get-VSTeamAgent -PoolId <Int32> -Id <Int32> [<CommonParameters>]

DESCRIPTION

Returns the agents in a pool.

EXAMPLES

Example 1

Get-VSTeamAgent -PoolId 5

This command retrieves all agents within the pool with the ID 5.

Example 2

Get-VSTeamAgent -PoolId 3 -Id 42

This example fetches the agent with the ID 42 within the pool with the ID 3.

Example 3

$agent = Get-VSTeamAgent -PoolId 1 -Id 91
$agent.systemCapabilities.PSObject.Properties['Agent.OS'].Value

In this example, the agent with the ID 91 in the pool with the ID 1 is fetched. Afterwards, the system capability 'Agent.OS' of the agent is displayed.

Example 4

$agents = Get-VSTeamAgent -PoolId 2
$agents | Where-Object { $_.status -eq "Online" }

This command retrieves all agents in the pool with the ID 2 and then filters to show only those agents that are currently online.

PARAMETERS

-PoolId

Id of the pool.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Id

Id of the agent to return.

Type: Int32
Parameter Sets: ByID
Aliases: AgentID

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

OUTPUTS

System.Object

NOTES

To read system capabilities that contain dots you have to use the PSObject Properties property.

(Get-VSTeamAgent 1 91).systemCapabilities.PSObject.Properties['Agent.OS'].Value

Prerequisites:

Set the account and version that all calls will use with Set-VSTeamAccount. Default version sets to API version 3.0 (TFS2017) if not manually set.

tips:

  • check called version of the API with Get-VSTeamAPIVersion or Get-VSTeamInfo
  • use Set-VSTeamDefaultProject to set default project for every call
  • use Set-VSTeamDefaultAPITimeout to change the default timeout of 60 seconds for all calls.
  • use Profiles to load an account and the correct version