我运行下面的脚本来显示我们服务器的所有当前连接,有没有办法在写入文件时过滤它而只提供活动会话?
@ECHO OFF
REM Delete previous output file
del currentsessions.txt
FOR /F "delims=," %%i IN (AXServers.txt) DO (
echo %%i >> currentsessions.txt
QUERY SESSION /SERVER:%%i >> currentsessions.txt
)
并且输出如下
答案 0 :(得分:0)
根据npocmaka发表评论,调整为以下代码。
@ECHO OFF
REM Delete previous output file
del currentsessions.txt
FOR /F "delims=," %%i IN (AXServers.txt) DO (
echo %%i >> currentsessions.txt
QUERY SESSION /SERVER:%%i|find "Active" >> currentsessions.txt
)