Turns script debugging features on and off.
Syntax Set-PSDebug [-trace int] [-step] [-strict] [CommonParameters] Set-PSDebug [-off] [CommonParameters] Key -trace int Set the trace level: 0 - Off 1 - trace script lines as they are executed 2 - trace script lines, variable assignments, function calls and scripts. -step Turn on script stepping. Before each line is run, PowerShell will prompt to stop, continue or enter a new interpreter level to inspect the state of the script. (Step automatically sets Trace =1) -strict Throw an exception if a variable is referenced before being assigned a value. -off Turn off all debugging features. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Set the trace level to 2:
PS C:\> set-psdebug -trace 2;
Turns stepping on:
PS C:\> set-psdebug -step
Turn off all debugging features:
PS C:\> set-psdebug -off
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it" ~ Brian W. Kernighan
Write-Debug - Write a debug message to the host display
Set-StrictMode - Enforce coding rules in expressions & scripts
Equivalent bash command: set -x / +x - turn debug on/off, or bash -x myscript.sh