How to determine the session id on remote machine for usage with psexec -i using script/powershell/…?

后端 未结 3 849
独厮守ぢ
独厮守ぢ 2020-12-30 14:11

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

3条回答
  •  抹茶落季
    2020-12-30 14:49

    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
    

提交回复
热议问题