Get-AutomateComputer -ComputerID could easily support pipline input
Closed this issue · 2 comments
blckpythn commented
blckpythn commented
This would allow commands such as 1..10 | get-automatecomputer -computerid $_
DarrenWhite99 commented
It's not as simple as enabling pipeline support for the parameter: Without rebuilding the function, only the last ID is processed:
Baseline: Non-Pipeline provided IDs
PS C:\> Get-AutomateComputer (1..8) | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
3 Server 172.17.254.32
4 Server 172.17.254.33
5 Server 172.17.254.30
8 Server 172.17.254.20
PS C:\> Get-AutomateComputer @(1..8) | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
3 Server 172.17.254.32
4 Server 172.17.254.33
5 Server 172.17.254.30
8 Server 172.17.254.20
Passing via pipeline:
PS C:\> (1..8) | Get-AutomateComputer | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
8 Server 172.17.254.20
PS C:\> 1..8 | Get-AutomateComputer | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
8 Server 172.17.254.20
PS C:\> @(1..8) | Get-AutomateComputer | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
8 Server 172.17.254.20
The only way to get it to work is to pass an array as a single object, which isn't intuitive:
PS C:\> @(,@(1..8)) | Get-AutomateComputer | ft Computerid,Type,LocalIPAddress
ComputerID Type LocalIPAddress
---------- ---- --------------
3 Server 172.17.254.32
4 Server 172.17.254.33
5 Server 172.17.254.30
8 Server 172.17.254.20
.