Получить количество RDP-сессий на терминальных серверах
Получить количество RDP
—сессий на терминальных серверах:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | @echo offrem Script Workrem Author Ollo Alexander aka ekzorchikrem Check RDP Connection on TSset host1=ts1.polygon.localset host2=ts2.polygon.localset host13=u2-ts13.polygon.localset host9=ts9.polygon.localset host10=ts10.polygon.localset host11=ts11.polygon.localset host12=ts12.polygon.localset host13=u2-ts13.polygon.localset host14=u2-ts14.polygon.localset host15=u2-ts15.polygon.local rem TS1echo TS1set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host1% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host1% = %COUNTA%,^|usersconnected=%COUNTA% rem TS2echo TS2set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host2% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host2% = %COUNTA%,^|usersconnected=%COUNTA% rem TS9echo TS9set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host9% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host9% = %COUNTA%,^|usersconnected=%COUNTA% rem TS10echo TS10set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host10% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host10% = %COUNTA%,^|usersconnected=%COUNTA% rem TS11echo TS11set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host11% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host11% = %COUNTA%,^|usersconnected=%COUNTA% rem TS12echo TS12set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host12% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host12% = %COUNTA%,^|usersconnected=%COUNTA% rem TS13echo TS13set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host13% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host13% = %COUNTA%,^|usersconnected=%COUNTA% rem ts14echo TS14set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host14% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host14% = %COUNTA%,^|usersconnected=%COUNTA% rem ts15echo TS15set COUNTA=SET /a COUNTA=0FOR /f “TOKENS=1 DELIMS= ” %%G IN (‘query session /server:%host15% /vm ^|find /I “rdp-tcp”‘) DO SET /a COUNTA+=1ECHO Active sessions on %host15% = %COUNTA%,^|usersconnected=%COUNTA% |
На этом пока, все, с уважением автор блога Олло Александр aka ekzorchik.