Understanding standard redirection in PowerShell

When I first started using the command line interface, I was daunted by < and > and >> at first. Then, I entirely stopped using the command line interface for a while and went back to the Windows administrator ways, albeit with an unusual-for-a-Windows-admin level of use of keyboard shortcuts (it's all about the speed and efficiency!).

When PowerShell came along, I had forgotten about those operators; I simply went ahead and understood the concept of object and pipelines, and worked for years that way. Switching to Linux at home made me want to know the "Linux way" of using the terminal. The operators came back to haunt me. I simply installed PowerShell on Linux.

Redirection in PowerShell mainly relies on streams. And streams are covered in a different chapter. For now, we stick with the default stream, which is, Success.

This recipe covers the different, simple redirections to help with basic administration. We shall come back to streams while understanding the concepts of error handling.

Before we begin, let us understand that PowerShell is very different from Bash in terms of redirection, although it packs some minor similarities; similarities enough to make you not go away, but rather appreciate the flexibility of the object model, and the uniformity of use.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.242.165