18.2. The set-PSDebug Cmdlet
The set-PSDebug cmdlet turns Windows PowerShell script debugging on and off.
NOTE
Members of the Windows PowerShell team have indicated a full script debugger is likely to be available in a future version of Windows PowerShell. As far as I am aware, no indication has been given of which version or of a likely timescale.
The set-PSDebug cmdlet supports the common parameters (described in Chapter 6) and the following parameters. Each of the listed parameters is optional. All are named parameters.
Trace — Specifies how tracing is to be carried out. Permitted values for this property are the Int32 values 0, 1, and 2.
Step — Step through code one statement at a time.
Strict — Specifies that an exception should be thrown if a variable is referenced before it has been assigned a value.
Off — Turn debugging off.
The values of the Trace parameter have the meanings shown in the following table.
Trace Parameter Value | Meaning |
---|---|
0 | No debugging. |
1 | Trace script lines. |
2 | Trace script lines, variable assignments, function calls, and scripts. |
The following commands show what debug information is (or is not) displayed when the simple assignment statement
$a = 10
is executed multiple times. First the statement is run with debug set to off; then, in succession, debug is set to Trace 0, Trace 1, Trace 2, and, finally, Off again.
As you can see in Figure 18-7, Trace 0 is the same as setting debugging to Off. No debugging information is displayed. When debugging is set to Trace 1, the ...
Get Professional Windows® PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.