Pipeline, Get-Member and Formatting

Pipeline |

A pipeline is a series of commands connected by pipeline operators (|)(ASCII 124). Each pipeline operator sends the results of the preceding command to the next command.

Every action you take in Windows PowerShell occurs within the context of objects. As data moves from one command to the next, it moves as one or more identifiable objects. An object, then, is a collection of data that represents an item. An object is made up of three types of data: the objects type, its methods, and its properties.

When working with objects, you can use their properties and methods in commands to take action and manage data.

When commands are combined in a pipeline, they pass information to each other as objects. When the first command runs, it sends one or more objects down the pipeline to the second command. The second command receives the objects from the first command, processes the objects, and then passes new or revised objects to the next command in the pipeline. This continues until all commands in the pipeline run.

Methods

A "method" is a set of instructions that specify an action you can perform on the object. For example, the FileInfo object includes the CopyTo method that copies the file that the FileInfo object represents.

Properties

Most objects have properties. Properties are the data that is associated with an object. Different types of object have different properties. For example, a FileInfo object, which represents a file, has an IsReadOnly property that contains $True if the file the read-only attribute and $False if it does not. A DirectoryInfo object, which represents a file system directory, has a Parent property that contains the path to the parent directory.

Get-Member

The Get-Member cmdlet gets the members, the properties and methods, of objects.

get-service | get-member

Formatting

  • Format-Table (ft)

    • Formats the output as a table.

  • Format-List (fl)

    • Formats the output as a list of properties in which each property appears on a new line.

  • Out-GridView (ogv) [GUI]

    • Sends output to an interactive table in a separate window.

get-service App* | format-table -AutoSize    # Output1
get-service App* | format-list               # Output2
get-service App* | out-gridview              # Output3

Last updated