Tracing and Debugging
The three facilities for tracing and debugging in PowerShell are
the Set-PsDebug cmdlet, the Trace-Command cmdlet, and verbose cmdlet
output.
The Set-PsDebug Cmdlet
The Set-PsDebug cmdlet allows
you to control tracing, stepping, and strict mode in
PowerShell.
Parameters of the Set-PsDebug cmdlet | |
|---|---|
Parameter | Description |
| Sets the amount of tracing detail that PowerShell outputs when running commands. A
value of |
| Enables and disables per-command stepping. When enabled, PowerShell prompts you before it executes a command. |
| Enables and disables strict mode. When enabled, PowerShell throws a terminating error if you attempt to reference a variable that you have not yet defined. |
| Turns off tracing, stepping, and strict strict mode. |
The Trace-Command Cmdlet
Trace-Command CommandDiscovery -PsHost { gci c:\ }The Trace-Command cmdlet
exposes diagnostic and support information for PowerShell commands.
PowerShell groups its diagnostic information into categories called
Trace Sources.
A full list of trace sources is available through the Get-TraceSource cmdlet.
For more information about the Trace-Command cmdlet, type Get-Help Trace-Command.
Verbose Cmdlet Output
<Cmdlet> -VerbosePowerShell commands can generate verbose output using the
Write-Verbose cmdlet ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access