| external help file | Microsoft.PowerShell.Commands.Management.dll-Help.xml |
|---|---|
| Locale | en-US |
| Module Name | Microsoft.PowerShell.Management |
| ms.date | 07/24/2024 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.management/debug-process?view=powershell-7.6&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Debug-Process |
Debugs one or more processes running on the local computer.
Debug-Process [-Name] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
Debug-Process [-Id] <Int32[]> [-WhatIf] [-Confirm] [<CommonParameters>]
Debug-Process -InputObject <Process[]> [-WhatIf] [-Confirm] [<CommonParameters>]
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.
Debug-Process -Name powershellThis command attaches a debugger to the PowerShell process on the computer.
Debug-Process -Name note*This command attaches a debugger to all processes that have names that begin with note.
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.
Debug-Process -Id 1132, 2028This command attaches a debugger to the processes that have process IDs 1132 and 2028.
Get-Process powershell | Debug-ProcessThis 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.
Debug-Process -Id $PIDThis 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.
$P = Get-Process powershell
Debug-Process -InputObject $PThis 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.
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.
Type: System.Int32[]
Parameter Sets: Id
Aliases: PID, ProcessId
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies 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.
Type: System.Diagnostics.Process[]
Parameter Sets: InputObject
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseSpecifies 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.
Type: System.String[]
Parameter Sets: Name
Aliases: ProcessName
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can pipe a process ID to this cmdlet.
You can pipe a process object to this cmdlet.
You can pipe a process name to this cmdlet.
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 the MSDN library.