Recently I had to learn what the session ID was in Windows in order to get PSExec to run a powershell script. Most of the time I noticed that the session ID on each machine is 1
, but one one of my machines I noticed it is 2
.
They key difference is that on the machines where it is 1
, I logged into Windows directly by being physically in front of the computer, but the machine where it is 2
I had restarted it from within a remote desktop connection, and then logged in for the first time again from within a remote desktop session (so, since I had restarted, I had never signed in directly by being physically in front of the computer).
Here's what the list of active sessions look like on both a machine with a session ID of 1
(top) and 2
(bottom):
Is there documentation on how this number is set? It's a little inconvenient that it isn't always 1
. I wouldn't have expected 2
to be chosen in the above observation, for example.
quser /server:computer123
. You can also used logoff command similarly and runlogoff <ID#> /server:computer123
where<ID#>
is just the numberical number value only from the quser command for the session ID of the user to logoff remotely. If you have appropriate permissions, the psexec may not be needed for this.