liveBook · Manning

Chapter 17: Input and output

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

The introduction explains why scripts may need user input and more control over displayed output, while limiting these techniques to scripts that interact with people.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why scripts may need user input and more control over displayed output, while limiting these techniques to scripts that interact with people.

Key terms: prompt a user for input, scripts that run unattended

17.1 Prompting for, and displaying, information

This section explains why PowerShell’s input and output can behave differently depending on the application hosting its engine.

Key terms: PowerShell engine, host application, console host, integrated host

17.2 Read-Host

This section explains how Read-Host prompts a user for text and how to keep the response in a variable.

Key terms: Read-Host, text prompt, variable

17.3 Write-Host

Explains how Write-Host displays text, why its pipeline behavior matters, and when another Write cmdlet is a better choice.

Key terms: Write-Host, pipeline, information stream, hosting application, -ForegroundColor, -BackgroundColor, Write-Verbose, Verbose stream

17.4 Write-Output

This section explains how Write-Output sends objects through the pipeline rather than directly to the screen, and why that difference affects what gets displayed.

Key terms: Write-Output, pipeline, Out-Default, Out-Host, formatting system, Write-Host, Where-Object, Length, default cmdlet

17.5 Other ways to write

This section explains how PowerShell’s alternative output commands differ from pipeline output, how their messages can be suppressed, and why their display location may vary.

Key terms: Write-Output, Continue, SilentlyContinue, configuration variable, Write-Host, Write-Information, information stream, Write-Error, error stream, hosting applications

17.6 Lab

17.7 Lab answers

17.8 Further exploration

Encourages readers to practice the chapter’s input and output cmdlets and keep syntax reminders for future use.

Where this is used later

Concepts explained in this chapter

← Chapter 16: Variables: A place to store your stuff Chapter 18: Sessions: Remote control with less work →

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.