In Unix shell, you can write this:
( cmd1 ; cmd2 ) | cmd3
In Windows Batch, you can write this
( cmd1 & cmd2 ) | cmd3
In both cases, the output of cmd1 and cmd2 is passed to cmd3 on stdin.
Is it possible to do the same in Powershell?
I haven't found a valid syntax that allows this. I'd expect a statement block to work, like this, but it doesn't:
{ cmd1 ; cmd2 } | cmd3
I can get it to work by declaring a function:
function f() {
cmd1
cmd2
}
f | cmd3
Is there a syntax that allows this to be done in-line?