Enter-PSHostProcess
로컬 프로세스를 사용하여 대화형 세션에 연결하고 입력합니다.
구문
Enter-PSHostProcess
[-Id] <Int32>
[[-AppDomainName] <String>]
[<CommonParameters>]
Enter-PSHostProcess
[-Process] <Process>
[[-AppDomainName] <String>]
[<CommonParameters>]
Enter-PSHostProcess
[-Name] <String>
[[-AppDomainName] <String>]
[<CommonParameters>]
Enter-PSHostProcess
[-HostProcessInfo] <PSHostProcessInfo>
[[-AppDomainName] <String>]
[<CommonParameters>]
Description
Enter-PSHostProcess cmdlet은 로컬 프로세스를 사용하여 대화형 세션에 연결하고 입력합니다.
Windows PowerShell을 호스트하고 원격 세션을 실행하는 새 프로세스를 만드는 대신 이미 Windows PowerShell을 실행 중인 기존 프로세스에서 원격 대화형 세션이 실행됩니다. 지정된 프로세스에서 원격 세션과 상호 작용하는 경우 실행 중인 Runspace를 열거한 다음 Debug-Runspace 또는 Enable-RunspaceDebug를 실행하여 디버그할 Runspace를 선택할 수 있습니다.
입력하려는 프로세스는 Windows PowerShell(System.Management.Automation.dll)을 호스팅해야 합니다. 프로세스를 찾은 컴퓨터에서 Administrators 그룹의 구성원이거나 프로세스를 시작한 스크립트를 실행하는 사용자여야 합니다.
디버그할 Runspace를 선택한 후 현재 명령을 실행 중이거나 디버거에서 중지된 경우 Runspace에 대한 원격 디버그 세션이 열립니다. 그런 다음 다른 원격 세션 스크립트를 디버그하는 것과 동일한 방식으로 Runspace 스크립트를 디버그할 수 있습니다.
종료를 두 번 실행하여 디버깅 세션에서 분리한 다음 프로세스와 대화형 세션을 분리하거나 기존 디버거 종료 명령을 실행하여 스크립트 실행을 중지합니다.
Name 매개 변수를 사용하여 프로세스를 지정하고 지정된 이름을 가진 프로세스가 하나만 있으면 프로세스가 입력됩니다. 지정된 이름을 가진 프로세스가 두 개 이상 있으면 Windows PowerShell에서 오류를 반환하고 지정된 이름으로 찾은 모든 프로세스를 나열합니다.
원격 컴퓨터의 프로세스에 연결할 수 있도록 Enter-PSHostProcess cmdlet은 지정된 원격 컴퓨터에서 사용하도록 설정되므로 원격 Windows PowerShell 세션 내에서 로컬 프로세스에 연결할 수 있습니다.
예제
예제 1: Windows PowerShell ISE 프로세스 내에서 Runspace 디버깅 시작
In this example, you run **Enter-PSHostProcess** from within the Windows PowerShell console to enter the Windows PowerShell ISE process. In the resulting interactive session, you can find a runspace that you want to debug by running Get-Runspace, and then debug the runspace.
PS C:\> Enter-PSHostProcess -Name powershell_ise
[Process:1520]: PS C:\Test\Documents>
Next, get available runspaces within the process you have entered.
PS C:\> [Process:1520]: PS C:\> Get-Runspace
Id Name InstanceId State Availability
-- ------- ----------- ------ -------------
1 Runspace1 2d91211d-9cce-42f0-ab0e-71ac258b32b5 Opened Available
2 Runspace2 a3855043-cb16-424a-a616-685360c3763b Opened RemoteDebug
3 MyLocalRS 2236dbd8-2105-4dec-a15a-a27d0bfaacb5 Opened LocalDebug
4 MyRunspace 771356e9-8c44-4b70-9de5-dd17cb41e48e Opened Busy
5 Runspace8 3e517382-a97a-49ba-9c3c-fd21f6664288 Broken None
The runspace objects returned by **Get-Runspace** also have a NoteProperty called **ScriptStackTrace** of the running command stack, if available.Next, debug runspace ID 4, that is running another user's long-running script. From the list returned from **Get-Runspace**, note that the runspace state is **Opened**, and **Availability** is **Busy**, meaning that the runspace is still running the long-running script.
PS C:\> [Process:1520]: PS C:\> (Get-Runspace -Id 4).ScriptStackTrace
Command Arguments Location
------- --------- --------
MyModuleWorkflowF1 {} TestNoFile3.psm1: line 6
WFTest1 {} TestNoFile2.ps1: line 14
TestNoFile2.ps1 {} TestNoFile2.ps1: line 22
<ScriptBlock> {} <No file>
Start an interactive debugging session with this runspace by running the Debug-Runspace cmdlet.
PS C:\> [Process: 1520]: PS C:\> Debug-Runspace -Id 4
Hit Line breakpoint on 'C:\TestWFVar1.ps1:83'
At C:\TestWFVar1.ps1:83 char:1
+ $scriptVar = "Script Variable"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Process: 1520]: [RSDBG: 4]: PS C:\> >
After you are finished debugging, allow the script to continue running without the debugger attached by running the **exit** debugger command. Alternatively, you can quit the debugger with the **q** or **Stop** commands.
PS C:\> [Process:346]: [RSDBG: 3]: PS C:\> > exit
[Process:1520]: PS C:\>
When you are finished working in the process, exit the process by running the Exit-PSHostProcess cmdlet. This returns you to the PS C:\> prompt.
PS C:\> [Process:1520]: PS C:\> Exit-PSHostProcess
PS C:\>
매개 변수
-AppDomainName
형식: | String |
Position: | 1 |
Default value: | None |
필수: | False |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-HostProcessInfo
형식: | PSHostProcessInfo |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | False |
-Id
프로세스 ID별로 프로세스를 지정합니다. 프로세스 ID를 가져오려면 Get-Process cmdlet을 실행합니다.
형식: | Int32 |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-Name
프로세스 이름을 사용하여 프로세스를 지정합니다. 프로세스 이름을 얻으려면 Get-Process cmdlet을 실행합니다. 작업 관리자에서 프로세스의 속성 대화 상자에서 프로세스 이름을 가져올 수도 있습니다.
형식: | String |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-Process
프로세스 개체의 프로세스를 지정합니다. 이 매개 변수를 사용하는 가장 간단한 방법은 변수에 입력하려는 프로세스를 반환하는 Get-Process 명령의 결과를 저장한 다음 변수를 이 매개 변수의 값으로 지정하는 것입니다.
형식: | Process |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | False |
입력
참고
Enter-PSHostProcess 명령을 실행 중인 Windows PowerShell 세션의 프로세스를 입력할 수 없습니다. 그러나 Enter-PSHostProcess실행 중인 세션과 동시에 실행되는 다른 Windows PowerShell 세션 또는 Windows PowerShell ISE 세션의 프로세스를 입력할 수
. Enter-PSHostProcess Windows PowerShell을 호스팅하는 프로세스만 입력할 수 있습니다. 즉, Windows PowerShell 엔진을 로드했습니다.
프로세스 내에서 프로세스를 종료하려면 종료를 입력한 다음 Enter 키를 누릅니다.