Thursday, September 19, 2013

Count disconnected Terminal Server sessions via command line

One Server
query session | find /I “disc” /c

Multiple Servers
List servers in a file named C:\servers.txt

for /f %x in (C:\SERVERS.TXT) do @echo %x&@query session /server:%x | find /i "disc" /c