R W
asked on
Logging PSexec results
My script however some machines are not going to connect I am sure. How do I pass the results to a log file so that I can review what it missed?
@ECHO ON
set controlfile=serverlist.txt
FOR /F %%L IN (%controlfile%%) DO (
SET "line=%%L"
psexec \\%%L net user somesuer somepassword /add && net localgroup administrators "someuser" /add
)
ASKER
Tried this method I even tried >> \\servershare\log.txt and it didnt work. Txt file shows The command completed successfully. That is all it says
Try this:
@ECHO ON
set controlfile=serverlist.txt
FOR /F %%L IN (%controlfile%) DO (
SET "line=%%L"
psexec \\%%L net user somesuer somepassword /add 2>> logfilename.txt && net localgroup administrators "someuser" /add >> logfilename.txt
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect thanks
set controlfile=serverlist.txt
FOR /F %%L IN (%controlfile%%) DO (
SET "line=%%L"
echo %%L >> logfilename.txt
psexec \\%%L net user somesuer somepassword /add && net localgroup administrators "someuser" /add >> logfilename.txt
)