Debugging with VS Code
VS Code is probably the best tool for debugging PowerShell. It has all the debugging features most people will need, such as remote debugging capabilities for connecting to other machines; far too many to cover here. This section is going to cover the basics and show how we can use VS Code to perform the basic debugging procedures we’ve just covered in the command line.
In a new VS Code session, press Ctrl + Shift + P to open the Command Palette and type exam
; you should see a link for the PowerShell extension examples folder, as shown here:
Figure 10.13 – The PowerShell extension examples folder shortcut
In the File Explorer in the left-hand pane, double-click the DebugTest.ps1
file to open it.
This is quite a short tutorial script that is provided with the PowerShell VS Code extension. It consists of two functions, Do-Work
and Write-Item
. Neither function does very much; Do-Work
writes two lines of text, using...