I'm currently reading through 'PowerShell in a Month of Lunches', and I'm having a tough time understanding Chapter 19.6. The author mentions that PowerShell scripts only have a single pipeline, and the output formatting will differ from running the commands in the shell directly. However, I've tried using the same commands provided in the chapter and I'm not seeing the different results described.
The book instructs to copy two commands and run them in the PowerShell console, saying you'll run them as separate commands in distinct pipelines, but I end up getting identical results when running both in the script and in the shell. The commands I'm using are:
```
Get-Process | Where-Object { $_.Name -like "pwsh*" }
Get-Uptime
```
I also included filtering to keep the output concise. According to the author, when run through a script, the output should behave differently because two types of objects are sent through a single pipeline, leading to distinct formatting. But I get the same results regardless.
Is something possibly different in the version I'm using? I'm on PowerShell 7, just like the author. Would love to hear if anyone else has had this issue!
3 Answers
I've tried it too with a different command: `Get-Process` followed by `Get-Disk`, and it works as the author mentioned. Maybe something changed with the default output of `Get-Uptime` that affects its format when used in a script? That could be why the behavior is inconsistent for you.
It looks like when you copy-paste both commands together in the console, they're treated as one command unless you trigger an enter after each. If you do them one by one, then they work as intended. The differences have a lot to do with how the input is processed, especially now with tools like `PSReadLine` handling input differently.
I've had the same experience where `Get-Disk` returns a table when called on its own, but when I put it in a script with `Get-Uptime`, I noticed that it outputs all the properties and forces a list format. It seems like there’s a change in how these cmdlets behave collectively vs. individually in the console. Can’t really explain it either!
Yeah, I noticed the same thing with `Get-Uptime`. When I call it directly, it doesn't show all the details, but wrapped in a script, it behaves differently.

Exactly! The behavior you're seeing is likely due to the way that pasting commands is processed in the PowerShell console vs. running a script. If you try it without `PSReadLine`, it can behave closer to what the book describes.