我有一个脚本从arround 2k服务器检索PowerPath许可证信息,我用简单的脚本自动执行了这个:
for /F %%A in (server_list.txt) do (
echo %%A >> PP_license.txt
psexec \\%%A powermt check_registration | find "Key" >> PP_license.txt
)
但我对这个输出文件不满意,现在看起来像这样:
server1
Key XXXX-XXXX
server2
Key YYYY-YYYY
是否可以操纵它来获得如下输出:
server1 XXXX-XXXX
server2 YYYY-YYYY
如果没有,那么我将尝试在PowerShell中执行此操作。
答案 0 :(得分:2)
for /F %%A in (server_list.txt) do (
for /F "tokens=1*" %%B in ('psexec \\%%A powermt check_registration ^| find "Key" ') do (
echo %%A %%C>> PP_license.txt
)
)
答案 1 :(得分:1)
for /F %%A in (server_list.txt) do (
(echo|set /p"= %%A ")>> PP_license.txt
for /f "tokens=* delims=" %%x in ('psexec \\%%A powermt check_registration ^| find "Key" ') do (
(echo %%x)>>PP_license.txt
)
)
答案 2 :(得分:1)
试试这个
ren PP_license.txt PP_license.tmp
3<PP_license.tmp (
:loop
set /p srv=<&3
set /p key=<&3
if "%srv%"=="" goto :end
<nul set /p=%srv% >> PP_license.txt
for /f "tokens=2" %%a in "%key%" do set key=%%a
Echo %key% >> PP_license.txt
goto :loop
:end
)
而应完全按照您的意愿行事。
莫纳