Link to home
Start Free TrialLog in
Avatar of R W
R WFlag for United States of America

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
)

Open in new window

Avatar of Mohammed Khawaja
Mohammed Khawaja
Flag of Canada image

@ECHO ON

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
)
Avatar of R W

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
)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of R W

ASKER

Perfect thanks