My PC sometime is rebooted overnight by patching process without noticing me, I do not remember which windows servers I remote control login to, I need to logoff those otherwise when my windows password change next time then my account will be locked because those orphaned login.
I saved the remote desktop connection manager configuration in a few groups, for example, one group name is others.rdg.
I use this power shell command to query the login session on the servers:
PS C:\dropit\remotedesktop> findstr "<name>" others.rdg|foreach-object { $_ -replace "<name>","query session /server:"}|foreach-object { $_ -replace "</name>", ""}
query session /server:servername1
query session /server:servername2
...
copy and paste the output and run it either in powershell or in dos command, I will have the list of sessions who logon to those windows server, then I can logoff from there.
PS C:\dropit\remotedesktop> query session /server:servername1
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
console 1 Conn
jsun 5 Disc
rdp-tcp 65536 Listen
I saved the remote desktop connection manager configuration in a few groups, for example, one group name is others.rdg.
I use this power shell command to query the login session on the servers:
PS C:\dropit\remotedesktop> findstr "<name>" others.rdg|foreach-object { $_ -replace "<name>","query session /server:"}|foreach-object { $_ -replace "</name>", ""}
query session /server:servername1
query session /server:servername2
...
copy and paste the output and run it either in powershell or in dos command, I will have the list of sessions who logon to those windows server, then I can logoff from there.
PS C:\dropit\remotedesktop> query session /server:servername1
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
console 1 Conn
jsun 5 Disc
rdp-tcp 65536 Listen
One can also download this psloggedon from here:
ReplyDeletehttps://docs.microsoft.com/en-us/sysinternals/downloads/psloggedon
C:\download\Microsoft\PSTools>psloggedon \\servername
PsLoggedon v1.35 - See who's logged on
Copyright (C) 2000-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Users logged on locally:
21-04-13 8:49:22 AM BCFERRIES\a.JSun
NT SERVICE\SSISTELEMETRY150
NT SERVICE\SQLTELEMETRY
NT SERVICE\MsDtsServer150
NT SERVICE\MSSQLFDLauncher
NT SERVICE\SQLSERVERAGENT
NT SERVICE\MSSQLSERVER
Users logged on via resource shares:
21-04-13 8:55:59 AM domain\a.JSun