I want to find out if I could echo multiple objects in powershell. I tried searching this and found this, but It wasn't what I was looking for.
Basically, I want to be able to echo two different objects (that can both be seen in foreach-object
) with a single command.
Expected input & output
PS C:\> <echo multiple object command> "test" | % {echo "$_ test"}
test test
test test
Input and output for what I've tried.
PS C:\> echo "test`ntest" | % {echo "$_ test"}
test
test test
Expected output:
test test
test test
If I do this with get-process
for example, like so:
PS C:\> get-process | % {echo "$_ and this"}
Output:
Process1 (Thing) and this
Process2 (Thing) and this
Process3 (Thing) and this
Process4 (Thing) and this
This will also work with arrays like so:
PS C:\> $test = @("test1","test2","test3")
PS C:\> $test | % {echo "$_ and this"}
test1 and this
test2 and this
test3 and this
But so far I have not found any way to replicate this with specifying the certain objects other than arrays
Summary: Is there a way to write a multiple object output in powershell 5.1?
So all in all, I want to echo a multi-object output?