PowerShell Object Pipeline
On .NET projects today, a common theme with setup and builds scripts is psake and Windows PowerShell. A development team member on my current project is a PowerShell Ninja, which prompted me to learn more about PowerShell this weekend. I watched an excellent five-part webcast series by Ed Wilson ( @ScriptingGuys) on Scripting with Windows PowerShell that got me up to speed in a couple hours.
These webcasts changed my viewpoint of PowerShell from being a VBScript replacement (that I never used) to a powerful scripting framework and shell. I have modified and extended existing psake build scripts, but I did not realize some of the key concepts lurking just below the surface.
I did not consider it possible that PowerShell pipelines objects between commands instead of strings due to the many years I spent developing shell scripts on UNIX/Linux. Once Ed explained this key concept, I discarded my preconceived understanding of PowerShell and watched the entire series to learn more.
I can only imagine how useful object pipelining in UNIX shell scripts would be after witnessing the equivalent in PowerShell. For example, getting basic process information from the bash prompt on the Mac can be done with the ps command. The output of the ps command can be manipulated as standard ASCII text:
Conversely, the same process information in PowerShell passes along the entire process object to the next command to inspect:
Object passing between commands in PowerShell is just a minor fact hardly worth blogging about, but it is a fundamental reason you should ignore decades of preconceived ideas about shell scripting and give PowerShell an honest look.