Debug-Job cmdlet을 사용하면 작업 내에서 실행되는 스크립트를 디버그할 수 있습니다. 이 cmdlet은 원격 세션에서 실행되는 PowerShell 워크플로 작업, 백그라운드 작업 및 작업을 디버그하도록 설계되었습니다.
Debug-Job 실행 중인 작업 개체, 이름, ID 또는 인스턴스 ID를 입력으로 허용하고 실행 중인 스크립트에서 디버깅 세션을 시작합니다. 디버거 quit 명령은 작업 및 실행 스크립트를 중지합니다.
exit 명령은 디버거를 분리하고 작업을 계속 실행할 수 있도록 합니다.
예제
예제 1: 작업 ID별로 작업 디버그
이 명령은 ID가 3인 실행 중인 작업으로 나뉩니다.
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"
매개 변수
-BreakAll
디버거가 연결될 때 현재 위치에서 즉시 실행을 중단할 수 있습니다.
이 매개변수는 실험적 기능으로만 사용할 수 있습니다. 자세한 내용은 실험적 기능 사용참조하세요.
이 cmdlet은 일반적인 매개 변수인 -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction 및 -WarningVariable 매개 변수를 지원합니다. 자세한 내용은 about_CommonParameters를 참조하세요.