Powershell Using Start-Process in PSSession to Open Notepad

后端 未结 4 564
孤独总比滥情好
孤独总比滥情好 2020-12-03 19:29

I\'ve created a pssession on a remote computer and entered that possession. From within that session I use start-process to start notepad. I can confirm that notepad is ru

4条回答
  •  我在风中等你
    2020-12-03 20:09

    When you use New-PSSession and then RDP into that same computer, you're actually using two separate and distinct user login sessions. Therefore, the Notepad.exe process you started in the PSSession isn't visible to your RDP session (except as another running process via Task Manager or get-process).

    Once you've RDP'd into the server (after doing what you wrote in your post), start another Notepad instance from there. Then drop to PowerShell & run this: get-process -name notepad |select name,processid

    Note that there are two instances, each in a different session.

    Now open up Task Manager and look at the user sessions. Your RDP session will probably be listed as session 1.

    Now quit Notepad and run get-process again. You'll see one instance, but for session 0. That's the one you created in your remote PSSession.

提交回复
热议问题