1

I've got a script to retrieve PowerPath license information from arround 2k servers, I've automated this with simple script:

for /F %%A in (server_list.txt) do (
echo %%A >> PP_license.txt
psexec \\%%A powermt check_registration | find "Key" >> PP_license.txt
)

But I'm not happy with this output file, which now looks like this:

server1
Key XXXX-XXXX
server2
Key YYYY-YYYY

Is it possible to manipulate this to get output like:

server1 XXXX-XXXX
server2 YYYY-YYYY

?

If not then I'll try do this in PowerShell.

3 Answers 3

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
    )
)
Sign up to request clarification or add additional context in comments.

Comments

1

Try this

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
)

And that should do exactly what you want.

Mona

Comments

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
    )
)

3 Comments

Ok, that almost works :) But now the output is like this: server1 key XXXX-XXXXserver2 key YYYY-YYYYserver3 key ZZZZ-ZZZZ
This comments give bad format ;) So now I have: server1 (newline) key XXXX server2 (newline) key YYYY, What I want to get is: server1 xxxx (newline) server2 yyyy ...
Despite you have your answer I've edited mine again.Now it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.