如何确定远程计算机上的会话ID与PSEXEC使用-i使用脚本/ PowerShell中/ ...? [英] How to determine the session id on remote machine for usage with psexec -i using script/powershell/...?

查看:762
本文介绍了如何确定远程计算机上的会话ID与PSEXEC使用-i使用脚本/ PowerShell中/ ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要脚本或powershell命令,将能够确定已登录用户远程机器上的特定的会话ID的,后面将要用作参数来在该远程GUI处理的PSEXEC -i执行在远程计算机上用户的会话。

I am in need of a script or powershell command that will be able to determine the session id of a specific logged in user on remote machine, to be later used as parameter to the psexec -i execution of remote gui process on that session of that user on the remote machine.

到目前为止,我设法用

psexec \\remoteMachine -u user -p pswrd query session

获取远程计算机上的会话列表:

to get list of sessions on the remote machine:

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
console                                     0  Conn    wdcon
rdp-tcp#919       user                     1  Active  rdpwd
rdp-tcp#916       user                     3  Active  rdpwd

所以我想我能以某种方式隔离所需的ID,并用它 - 但没有成功地做到这一点尚未

so i guess i could somehow isolate the needed id and use it - but haven't managed to do that yet

任何想法?
也许其他的 - 简单的方法

Any ideas? Maybe other - simpler ways?

感谢您的帮助。

推荐答案

随着PSTerinalServices PowerShell模块,你可以得到用户会话和ID。结果
该模块可以在这里找到: HTTP://$c$c.msdn.microsoft.com/ PSTerminalServices

With the PSTerinalServices powershell module you can get the user sessions and IDs.
The module can be found here: http://code.msdn.microsoft.com/PSTerminalServices

PS > Get-TSSession -UserName user1 -ComputerName pc1 | select UserName,SessionId

UserName SessionId
-------- ---------
User             1

这篇关于如何确定远程计算机上的会话ID与PSEXEC使用-i使用脚本/ PowerShell中/ ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆