I need a script or powershell command that can determine the session ID of a specific registered user on a remote machine, which will later be used as a parameter to execute the psexec -i remote gui process on that user's session on the remote machine.
So far i have managed to use
psexec \\remoteMachine -u user -p pswrd query session
To get a list of sessions on a remote computer:
SESSIONNAME USERNAME ID STATE TYPE DEVICE console 0 Conn wdcon rdp-tcp
therefore, I suppose that I can somehow isolate the desired identifier and use it, but I have not managed to do it yet
Any ideas? Maybe others are simpler ways?
Thanks for the help.
scripting powershell automation psexec
ruslanoid
source share