liveBook · Manning

Chapter 6: The pipeline: Connecting commands

What you will learn in chapter 6 of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

The introduction contrasts ordinary command execution with PowerShell’s ability to connect commands in one-line sequences.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction contrasts ordinary command execution with PowerShell’s ability to connect commands in one-line sequences.

Key terms: cmdlet, parameters, one-line sequences

6.1 Connecting one command to another: Less work for you

This section introduces the pipeline as a way to pass one PowerShell command’s output to another command.

Key terms: pipeline, pipe, output, |

6.2 Exporting to a file

Introduces exporting PowerShell command output to files so it can be used beyond the screen.

Key terms: export, CSV, Get-Process

6.2.1 Exporting to CSV

This section shows how to pipe process information to a CSV file, inspect what the file contains, and import it later as a snapshot.

Key terms: Get-Process, Export-CSV, pipeline, mandatory positional parameter, CSV file, column headings, onscreen display, import, snapshot, live information

6.2.2 Exporting to JSON

This section explains why JSON is useful for exporting nested process thread information and how PowerShell converts that information to and from JSON.

Key terms: nested property, Threads property, ConvertTo-CSV, ConvertTo-Json, ConvertFrom-Json, Out-File, string on the pipeline

6.2.3 Exporting to XML

This section explains how PowerShell saves and reloads objects with CLIXML, when that format is useful, and how to find related commands.

Key terms: Export-Clixml, Import-Clixml, CLI XML, objects, Clixml, PowerShell, security-related portions, Get-Command, -Verb, Import

6.2.4 Out-File

This subsection introduces Out-File as a way to write pipeline data to a flat file.

Key terms: Out-File, pipeline, flat file

6.2.5 Comparing files

The section shows how to compare a saved PowerShell snapshot with a system’s current state and interpret the differences.

Key terms: Compare-Object, CLIXML, Import-Clixml, -ReferenceObject, -DifferenceObject, configuration baselines, -Property, Name, <=, =>

6.3 Piping to a file

This section explains how PowerShell sends formatted output to a file or the screen and shows how to find other Out- cmdlets.

Key terms: Out-File, >, character encodings, 80 columns, Out-Default, Out-Host, host, Help Out*, Get-Command Out*, Get-Command -Verb Out

6.4 Converting to HTML

This section shows how to turn command output into HTML and explains why converting data and saving it are separate pipeline steps.

Key terms: ConvertTo-Html, Out-File, pipeline, Export, ConvertTo-, ConvertTo-CSV, ConvertTo-Xml, Export-CSV, Export-Clixml

6.5 Using cmdlets that modify the system: Killing processes

This section shows how pipelines can feed system-modifying cmdlets and how confirmation and WhatIf help prevent unintended changes.

Key terms: Get-Process, Stop-Process, pipeline, impact level, $ConfirmPreference, -Confirm, -WhatIf

6.6 Common points of confusion

This section explains why files created by Export-CSV or Export-Clixml are usually best read with their matching Import commands rather than as raw text.

Key terms: Export-CSV, Export-Clixml, Get-Content, Import-CSV, Import-Clixml, -IncludeTypeInformation

6.7 Lab

6.8 Lab answers

Where this is used later

Concepts explained in this chapter

← Chapter 5: Working with providers Chapter 7: Adding commands →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.