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
