liveBook · Manning

F8 debugging

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

F8 debugging is an interactive debugging technique that executes a script one line or selected snippet at a time while preserving the console state.

F8 debugging runs a PowerShell script one line or selected snippet at a time in the VS Code Integrated Console, preserving the state between commands. It avoids repeatedly waiting for a long script to reach a failure. section 25.2

Use the technique in this sequence:

  • Open the script in VS Code and place the cursor on a line. section 25.2
  • Click Run Selection (F8) to execute the current line, or select several lines to execute that snippet. section 25.2
  • Change a variable in the console, then rerun a later line to inspect the resulting behavior. section 25.2
Write-Host 'hello'
$processName = 'pwsh'
Get-Process $processName

Use the short script to practice assigning a process name and querying matching processes one step at a time. section 25.2

Inspecting processes incrementally

Run `$processName = 'pwsh'`, then run `Get-Process $processName`. Change the variable to `code*` and rerun the query to inspect a different result without rerunning the entire script. section 25.2

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Demonstrates a practical VS Code workflow but does not explain debugger internals.
Examples
Uses a process-name variable, Get-Process, selected snippets, and a lab that improves script logging.
What it assumes
Assumes a PowerShell script and VS Code with the PowerShell extension, while teaching the execution workflow directly.
What you can do after
Diagnose/debug with VS Code by executing selected PowerShell code and inspecting results incrementally.
How it connects
Connects PowerShell scripts with Visual Studio Code, the Integrated Console, logging, and breakpoint debugging.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.