liveBook · Manning

Chapter 25: Debugging techniques

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

The introduction distinguishes bugs from anticipated errors and frames debugging as finding mistakes in scripts.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction distinguishes bugs from anticipated errors and frames debugging as finding mistakes in scripts.

Key terms: errors and exceptions, bugs

25.1 Output everything

Shows how PowerShell output streams can reveal what a script is doing and help locate a bug, especially when the script runs in a noninteractive environment.

Key terms: Write-* statements, Write-Debug, debug stream, debug preference, Continue, Azure Pipelines, GitHub Actions, PowerShell’s streams

25.2 One line at a time

This section shows how to debug a PowerShell script incrementally in VS Code by running selected code in the PowerShell Integrated Console and inspecting its state.

Key terms: F8 debugging, Run Selection, PowerShell Integrated Console, $processName, PowerShell: Restart Current Session, parameters, variables, functions

25.3 Hey, script, stop right there . . . with breakpoints

Explains how to set a breakpoint in VS Code and run a PowerShell script so it pauses at that line for inspection.

Key terms: breakpoint debugging, breakpoints, F8 debugging, gutter, Run button, F5, with debugging

25.4 Lab

Concepts explained in this chapter

← Chapter 24: Handling errors Chapter 26: Tips, tricks, and techniques →

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.