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 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
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
.
PowerShell commands can generate verbose output using the
Write-Verbose
cmdlet (if written as
a script,) or the WriteVerbose()
API (when written as a cmdlet.)
The $VerbosePreference
automatic variable allows you to control how PowerShell handles
verbose output. It supports the following values:
VerbosePreference automatic variable values | |
---|---|
Value | Meaning |
| Do not display verbose output. This is the default |
| Treat verbose output as a terminating error. |
| Display verbose output and continue execution of the current cmdlet, script, function, or pipeline. |
| Display a prompt that asks how PowerShell should treat this verbose output. |
Most cmdlets allow you to configure this explicitly by passing
one of the above values to its Verbose
parameter.
3.15.25.32