Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Debug-Process

Debug-Process

microsoft.powershell.commands.management.dll

Synopsis

Debugs one or more processes running on the local computer.

Syntax

Debug-Process [-Name] [-Confirm] [-WhatIf] [<CommonParameters>]

Debug-Process [-Id] [-Confirm] [-WhatIf] [<CommonParameters>]

Debug-Process [-InputObject] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The Debug-Process cmdlet attaches a debugger to one or more running processes on a local computer. You can specify the processes by their process name or process ID (PID), or you can pipe process objects to Debug-Process.

Debug-Process attaches the debugger that is currently registered for the process. Before using this cmdlet, verify that a debugger is downloaded and correctly configured.

Parameters

-Id <Int32[]>

Specifies the process IDs of the processes to be debugged. The parameter name ("-Id") is optional.

To find the process ID of a process, type "get-process".

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-InputObject <Process[]>

Specifies the process objects that represent processes to be debugged. Enter a variable that contains the process objects or a command that gets the process objects, such as a Get-Process command. You can also pipe process objects to Debug-Process.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-Name <String[]>

Specifies the names of the processes to be debugged. If there is more than one process with the same name, Debug-Process attaches a debugger to all processes with that name. The parameter name ("Name") is optional.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

System.Int32, System.Diagnostics.Process, System.String

Return Type

None

Notes

This cmdlet uses the AttachDebugger method of the Windows Management Instrumentation (WMI) Win32_Process class. For more information about this method, see "AttachDebugger Method" in the MSDN library at http://go.microsoft.com/fwlink/?LinkId=143640.

Examples

-------------------------- EXAMPLE 1 --------------------------

This command attaches a debugger to the PowerShell process on the computer.

PS C:\>debug-process -name powershell

-------------------------- EXAMPLE 2 --------------------------

This command attaches a debugger to all processes that have names that begin with "sql".

PS C:\>debug-process -name sql*

-------------------------- EXAMPLE 3 --------------------------

This command attaches a debugger to the Winlogon, Explorer, and Outlook processes.

PS C:\>debug-process winlogon, explorer, outlook

-------------------------- EXAMPLE 4 --------------------------

This command attaches a debugger to the processes that have process IDs 1132 and 2028.

PS C:\>debug-process -id 1132, 2028

-------------------------- EXAMPLE 5 --------------------------

This command attaches a debugger to the PowerShell processes on the computer. It uses the Get-Process cmdlet to get the PowerShell processes on the computer, and it uses a pipeline operator (|) to send the processes to the Debug-Process cmdlet.

To specify a particular PowerShell process, use the ID parameter of Get-Process.

PS C:\>get-process powershell | debug-process

-------------------------- EXAMPLE 6 --------------------------

This command attaches a debugger to the current PowerShell processes on the computer.

It uses the $pid automatic variable, which contains the process ID of the current PowerShell process. Then, it uses a pipeline operator (|) to send the process ID to the Debug-Process cmdlet.

For more information about the $pid automatic variable, see about_Automatic_Variables.

PS C:\>$pid | debug-process

-------------------------- EXAMPLE 7 --------------------------

This command attaches a debugger to the MyApp processes on the Server01 and Server02 computers.

It uses the Get-Process cmdlet to get the MyApp processes on the Server01 and Server02 computers. It uses a pipeline operator to send the processes to the Debug-Process cmdlet, which attaches the debuggers.

PS C:\>get-process -computername Server01, Server02 -name MyApp | debug-process

-------------------------- EXAMPLE 8 --------------------------

This command attaches a debugger to the PowerShell processes on the local computer.

The first command uses the Get-Process cmdlet to get the PowerShell processes on the computer. It saves the resulting process object in the $p variable.

The second command uses the InputObject parameter of Debug-Process to submit the process object in the $p variable to Debug-Process.

PS C:\>$p = get-process powershell
PS C:\>debug-process -inputobject $p

Online Version
Debug-Process
Get-Process
Start-Process
Stop-Process
Wait-Process