Script debugging

Debugging in PowerShell is similar to that in other programming languages. Script debugging is available in the console host as well as in the PowerShell ISE; ISE has both GUI and cmdlet-based debugging, whereas console has only cmdlets to debug your scripts.

The debugging feature in the PowerShell ISE is available under the Debug tab, which is self-explanatory. Let's take a look at the breakpoints and debug cmdlets:

(Get-Command -Name *Debug*).Where({$_.Source -ne 'Azure' -and $_.CommandType -eq 'cmdlet'})
Get-Command -Name *BreakPoint

Note that in the first snippet, I used the where method to ignore Azure and to get only the core cmdlets; the output is illustrated in the following image:

Managing breakpoints

Windows PowerShell ...

Get Windows PowerShell for .NET Developers - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.