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

Question:

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.

So far i managed to use

to get list of sessions on the remote machine:

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?

Thanks for the help.

Answer:

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

Source:

How to determine the session id on remote machine for usage with psexec -i using script/powershell/…? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply