使用PowerShell远程启动在活动用户会话中启动程序

使用PowerShell远程启动在活动用户会话中启动程序

问题描述:

是否可以检测到特定用户在计算机上具有打开的会话并在该会话中打开进程以便用户可以使用PowerShell与应用程序交互远程处理?使用PowerShell远程启动在活动用户会话中启动程序

我该如何去检测哪些用户在机器上打开会话以及他们的状态是什么(活动,闲置,断开连接等)?我将如何在其中一个会话中启动应用程序?

UPDATE
我发现,你可以找出一个过程是在运行会话ID:

PS > (Get-Process notepad).SessionId 
1 

我似乎无法找到反正你时指定会话ID的过程尽管开始吧。

Powershell无法做到这一点,但微软的(以前的sysinternal的)工具PSEXEC可以做到这一点。看看-i参数:

-i   Run the program so that it interacts with the desktop of the 
      specified session on the remote system. If no session is 
      specified the process runs in the console session.