PowerShell Logo Small

Debug-Job



This is the built-in help made by Microsoft for the command 'Debug-Job', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Debugs a running background, remote, or Windows PowerShell Workflow job.

SYNTAX


Debug-Job [-Job] <Job> [-Confirm] [-WhatIf] [<CommonParameters>]
Debug-Job [-Id] <Int32> [-Confirm] [-WhatIf] [<CommonParameters>]
Debug-Job [-InstanceId] <Guid> [-Confirm] [-WhatIf] [<CommonParameters>]
Debug-Job [-Name] <String> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Debug-Job cmdlet lets you debug scripts that are running within jobs. The cmdlet is designed to debug Windows PowerShell Workflow jobs, background jobs, and jobs running
in remote sessions. Debug-Job accepts a running job object, name, ID, or InstanceId as input, and starts a debugging session on the script it is running. The debugger quit
command stops the job and running script. Starting in Windows PowerShell 5.0, the exit command detaches the debugger, and allows the job to continue running.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=512991
Get-Job
Receive-Job
Remove-Job
Resume-Job
Start-Job
Stop-Job
Suspend-Job
Wait-Job
about_Debuggers
about_Jobs
about_Job_Details
about_Remote_Jobs
about_Scheduled_Jobs

REMARKS

<

Examples


Example 1: Debug a job by job ID

PS C:\>Debug-Job –ID 3
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
3 Job3 RemoteJob Running True PowerShellIx TestWFDemo1.ps1
Entering debug mode. Use h or ? for help.

Hit Line breakpoint on 'C:\TestWFDemo1.ps1:8'

At C:\TestWFDemo1.ps1:8 char:5
+ Write-Output -InputObject "Now writing output:"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DBG:PowerShellIx]: PS C:\>> list

3:
4: workflow SampleWorkflowTest
5: {
6: param ($MyOutput)
7:
8:* Write-Output -InputObject "Now writing output:"
9: Write-Output -Input $MyOutput
10:
11: Write-Output -InputObject "Get PowerShell process:"
12: Get-Process -Name powershell
13:
14: Write-Output -InputObject "Workflow function complete."
15: }
16:
17: # Call workflow function
18: SampleWorkflowTest -MyOutput "Hello"



In this example, the debugger breaks into a running job with an ID of 3.