Share via


Debug-Process

Debugs one or more processes running on the local computer.

Syntax

Name (Default)

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

Id

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

InputObject

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

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.

Examples

Example 1

PS C:\> debug-process -name powershell

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

Example 2

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

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

Example 3

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

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

Example 4

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

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

Example 5

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

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.

Example 6

PS C:\> $pid | debug-process

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.

Example 7

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

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.

Example 8

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

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.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Id

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

Parameter properties

Type:

Int32[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:PID, ProcessId

Parameter sets

Id
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-InputObject

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.

Parameter properties

Type:

Process[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

InputObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

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.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:ProcessName

Parameter sets

Name
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

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

You can pipe a process ID (Int32), a process object (System.Diagnostics.Process), or a process name (String) to Debug-Process.

Outputs

None

This cmdlet does not generate any output.

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.