So I have a HyperV machine, and I can get the IP address thus:
Get-VM -VMName localdev | Select -ExpandProperty Networkadapters | Select -ExpandProperty IPAddresses | Select-Object -First 1
What I can't figure is how to 'pipe' this to SSH to connect to the machine in a single line.
Get-VM ....... | Select-Object -First 1 | ssh
^^^ this doesn't work.
I can do this but it's lacking in elegance:
$localdevip = Get-VM -VMName localdev | Select -ExpandProperty Networkadapters | Select -ExpandProperty IPAddresses |Select-Object -First 1
ssh $localdevip
Although this works, I want to understand Powershell better. How can I funnel the result from the Select-Object call into the parameter for the command (in the example it's SSH but could be anything) without assigning a variable?
Select-Objectincluding the-Fist 1parameter1.2.3.4yet if I add| sshit behaves as though I've passed no parameters and shows the help text.