CmdID / PowerShell / Cmdlets / Set
Set-PSDebug
Turns script debugging features on and off, sets the trace level, and toggles strict mode. PowerShell reference
From the PowerShell reference 4 parameters
What it does
Turns script debugging features on and off, sets the trace level, and toggles strict mode. The Set-PSDebug cmdlet turns script debugging features on and off, sets the trace level, and toggles strict mode. By default, the PowerShell debug features are off. When the Trace parameter has a value of 1, each line of script is traced as it runs. When the parameter has a value of 2, variable assignments, function calls, and script calls are also traced. If the Step parameter is specified, you're prompted before each line of the script runs.
Set-PSDebug [-Trace <Int32>] [-Step] [-Strict] [<CommonParameters>]Set-PSDebug [-Off] [<CommonParameters>]
Set the trace level
Set-PSDebug -Trace 2; foreach ($i in 1..3) {$i}IdentifyTurn on stepping
Set-PSDebug -Step; foreach ($i in 1..3) {$i}IdentifyUse strict mode
Set-PSDebug -Strict; $NewVarIdentifyTurn off debug features
Set-PSDebug -Off; foreach ($i in 1..3) {$i}IdentifyIts page in the reference: Set-PSDebug.
Parameters
-OffTurns off all script debugging features.-StepTurns on script stepping. Before each line runs, PowerShell prompts you to stop, continue, or enter a new interpreter level to inspect the state of the script.
Specifying the Step parameter automatically sets a trace level of 1.-StrictSpecifies that variables must be assigned a value before being referenced in a script. If a variable is referenced before a value is assigned, PowerShell returns an exception error. This is equivalent to Set-StrictMode -Version 1. For more information, see Set-StrictMode.-TraceSpecifies the trace level for each line in a script. Each line is traced as it's run.
The acceptable values for this parameter are as follows:
- 0: Turn script tracing off.
- 1: Trace script lines as they run.
- 2: Trace script lines, variable assignments, function calls, and scripts.