The specific use case is:
Get-NetTCPConnection -State Listen -LocalPort 6005 |
Get-Process -PID ???
Where ??? is the OwningProcess property of the output from the first cmdlet.
You have a couple options here that I can see. First, and simplest, you can pipe it to a ForEach-Object loop, and run Get-Process in that:
Get-NetTCPConnection -State Listen -LocalPort 6005 |
ForEach-Object {
Get-Process -PID $_.OwningProcess
}
Alternatively if you run Get-Help Get-Process -PArameter Id you can see that the Id parameter accepts values from the pipeline by property name, so you could create that property, and just pipe directly to Get-Process:
Get-NetTCPConnection -State Listen -LocalPort 6005 |
Select @{l='Id';e={$_.OwningProcess}} |
Get-Process
Couple of ways to do this. When the variables cannot be matched by property you can either use a ForEach-Object loop like in Joey's answer or if you wanted to do something crazy you can tailor the pipeline object to fits the needs.
Get-NetTCPConnection -State Listen -LocalPort 6005 |
Select-Object @{Name="PID";E={$_.OwningProcess}} |
Get-Process
Since Get-Process is looking to match the pipeline variable property PID we just use a calculated property to give it what it wants.
Using ForEach-Object in this case is much simpler. Just wanted you to know there was another way.