Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Format right


The next important practice in PowerShell is to format right. This means that any format cmdlets included in the pipeline should be at the far right of the pipeline. While filter left is primarily about efficiency, format right concerns the kinds of objects produced. To see this, have a look at the following output:

First, you can see that the Get-Service cmdlet outputs the ServiceController objects. Piping those ServiceController objects to Format-List, though, produces a series of objects with indecipherable properties, as shown in the following screenshot:

Once a formatting cmdlet has been executed, the only objects on the pipeline are PowerShell formatting objects which are only useful by the PowerShell host. As a general rule, the only cmdlets that can follow a formatting cmdlet in the pipeline are the output cmdlets that start with Out-. These output cmdlets are designed to interpret these formatting objects and render formatted output accordingly. Since pipelines always...