Open mathieuric opened 8 months ago
I wanted to delete all disabled agents from every agent pool so, intuitively, I wrote
Get-VSTeamPool | Get-VSTeamAgent | Where {-not $_.Enabled} | Remove-VSTeamAgent
but got this error
Remove-VSTeamAgent: The input object cannot be bound because it did not contain the information required to bind all mandatory parameters: PoolId
It would make sense for a "Remove" command to accept pipelined objects from a "Get" command with the same noun.
This is already supported by VSTeamPool. e.g. Get-VSTeamPool -Id 1 | Remove-VSTeamPool so one would expect the same of VSTeamAgent.
Get-VSTeamPool -Id 1 | Remove-VSTeamPool
VSTeamAgent
We already have the PoolId on the vsteam_lib.Agent type so it's just a matter of making the paramater accept pipeline input "ByPropertyName".
vsteam_lib.Agent
Makes removing a VSTeamAgent more intuitive and produces cleaner, more readable code.
:confused: Get-VSTeamAgent -PoolId 2 | foreach { Remove-VSTeamAgent -PoolId $_.PoolId -Id $_.AgentId } Get-VSTeamAgent -PoolId 2 | foreach { $_.PoolId | Remove-VSTeamAgent -Id $_.AgentId }
Get-VSTeamAgent -PoolId 2 | foreach { Remove-VSTeamAgent -PoolId $_.PoolId -Id $_.AgentId }
Get-VSTeamAgent -PoolId 2 | foreach { $_.PoolId | Remove-VSTeamAgent -Id $_.AgentId }
:relaxed: Get-VSTeamAgent -PoolId 2 | Remove-VSTeamAgent
Get-VSTeamAgent -PoolId 2 | Remove-VSTeamAgent
No response
Proposal
I wanted to delete all disabled agents from every agent pool so, intuitively, I wrote
Get-VSTeamPool | Get-VSTeamAgent | Where {-not $_.Enabled} | Remove-VSTeamAgent
but got this error
Remove-VSTeamAgent: The input object cannot be bound because it did not contain the information required to bind all mandatory parameters: PoolId
It would make sense for a "Remove" command to accept pipelined objects from a "Get" command with the same noun.
This is already supported by VSTeamPool. e.g.
Get-VSTeamPool -Id 1 | Remove-VSTeamPool
so one would expect the same ofVSTeamAgent
.We already have the PoolId on the
vsteam_lib.Agent
type so it's just a matter of making the paramater accept pipeline input "ByPropertyName".Solved Problem
Makes removing a VSTeamAgent more intuitive and produces cleaner, more readable code.
:confused:
Get-VSTeamAgent -PoolId 2 | foreach { Remove-VSTeamAgent -PoolId $_.PoolId -Id $_.AgentId }
Get-VSTeamAgent -PoolId 2 | foreach { $_.PoolId | Remove-VSTeamAgent -Id $_.AgentId }
:relaxed:
Get-VSTeamAgent -PoolId 2 | Remove-VSTeamAgent
Additional info / code snippets?
No response