Describes the Windows PowerShell debugger.
Debugging is the process of examining a script while it is running in
order to identify and correct errors in the script instructions. The
Windows PowerShell debugger is designed to help you examine and identify
errors and inefficiencies in your scripts.
Note: The Windows PowerShell debugger does not run remotely. To debug
a script on a remote computer, copy the script to the local
You can use the features of the Windows PowerShell debugger to examine a
Windows PowerShell script, function, command, or expression while it is
running. The Windows PowerShell debugger includes a set of cmdlets that
let you set breakpoints, manage breakpoints, and view the call stack.
Windows PowerShell offers several methods that you can use to debug
scripts, functions, and commands.
Method 1: The Set-PsDebug cmdlet offers basic script debugging features,
including stepping and tracing. For more information, type:
Method 2: Use the Set-StrictMode cmdlet to detect references to
uninitialized variables, to references to non-existent properties
of an object, and to function syntax that is not valid.
Method 3: Add diagnostic statements to a script, such as statements that
display the value of variables, statements that read input from
the command line, or statements that report the current
instruction. Use the cmdlets that contain the Write verb for
this task, such as Write-Host, Write-Debug, Write-Warning, and
Method 4: Use the Windows PowerShell debugger to debug a script. Or, use
the debugger to debug a function or script block that you typed
at the command prompt. You can set breakpoints, step through the
script, examine the values of variables, run diagnostics and
logging commands, and display the call stack.