Book Image

Mastering PowerShell Scripting - Fourth Edition

By : Chris Dent
5 (1)
Book Image

Mastering PowerShell Scripting - Fourth Edition

5 (1)
By: Chris Dent

Overview of this book

PowerShell scripts offer a convenient way to automate various tasks, but working with them can be daunting. Mastering PowerShell Scripting takes away the fear and helps you navigate through PowerShell's capabilities.This extensively revised edition includes new chapters on debugging and troubleshooting and creating GUIs (online chapter). Learn the new features of PowerShell 7.1 by working with parameters, objects, and .NET classes from within PowerShell 7.1. This comprehensive guide starts with the basics before moving on to advanced topics, including asynchronous processing, desired state configuration, using more complex scripts and filters, debugging issues, and error-handling techniques. Explore how to efficiently manage substantial amounts of data and interact with other services using PowerShell 7.1. This book will help you to make the most of PowerShell's automation features, using different methods to parse data, manipulate regular expressions, and work with Windows Management Instrumentation (WMI).
Table of Contents (26 chapters)
24
Other Books You May Enjoy
25
Index

Selecting and sorting

Select-Object acts on an input pipeline; either an existing collection of objects, or the output from another command. Select-Object can be used to select a subset of properties, to change properties, or to add new properties. Select-Object also allows a user to limit the number of objects returned.

Sort-Object can be used to perform both simple and complex sorting based on an input pipeline.

Using Select-Object is a key part of working with PowerShell, output can be customized to suit circumstances in a number of ways.

The Select-Object command

Select-Object is an extremely versatile command as shown by each of the following short examples, which demonstrate some of the simpler uses of the command.

Select-Object may be used to limit the properties returned by a command by name:

Get-Process | Select-Object -Property Name, Id 

Select-Object can limit the properties returned from a command using wildcards:

Get-Process | Select-Object...