다음을 통해 공유


Debug-Process

Debugs one or more processes running on the local computer.

구문

Name (기본값)

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

This cmdlet attaches the debugger that's registered for the process. Before using this cmdlet, verify that a debugger is installed and configured.

예제

Example 1: Attach a debugger to a process on the computer

Debug-Process -Name powershell

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

Example 2: Attach a debugger to all processes that begin with the specified string

Debug-Process -Name note*

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

Example 3: Attach a debugger to multiple processes

Debug-Process "Winlogon", "Explorer", "Outlook"

This command attempts to attach a debugger to the Winlogon, Explorer, and Outlook processes. Winlogon is a protected process. To debug Winlogon, you must run the command as an administrator.

Example 4: Attach a debugger to multiple process IDs

Debug-Process -Id 1132, 2028

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

Example 5: Use Get-Process to get a process then attach a debugger to it

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: Attach a debugger to a current process on the local computer

 Debug-Process -Id $PID

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

The command 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: Attach a debugger to a process that uses the InputObject parameter

$P = Get-Process powershell
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 variable named $P.

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

매개 변수

-Confirm

Prompts you for confirmation before running the cmdlet.

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False
별칭:cf

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Id

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

To find the process ID of a process, type Get-Process.

매개 변수 속성

형식:

Int32[]

Default value:None
와일드카드 지원:False
DontShow:False
별칭:PID, ProcessId

매개 변수 집합

Id
Position:0
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값: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 the Get-Process cmdlet. You can also pipe process objects to this cmdlet.

매개 변수 속성

형식:

Process[]

Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

InputObject
Position:Named
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Name

Specifies the names of the processes to be debugged. If there is more than one process with the same name, this cmdlet attaches a debugger to all processes with that name. The Name parameter is optional.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:False
DontShow:False
별칭:ProcessName

매개 변수 집합

Name
Position:0
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-WhatIf

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

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False
별칭:wi

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값: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.

입력

Int32

You can pipe a process ID to this cmdlet.

Process

You can pipe a process object to this cmdlet.

String

You can pipe a process name to this cmdlet.

출력

None

This cmdlet returns no output.

참고

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