Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Set-PSdebug

Set-PSdebug - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Turn script debugging on or off


-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.

       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)

       Throw an exception if a variable is referenced before being assigned a value.

       Turn off all debugging features.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -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