Rich said:
I have a text file named computers.txt that lists all my
workstations, one per line. For the life of me I can't figure out
how to use this with psexec logging in as the local admin with a -u
administrator to defrag all my workstations in this file. anyone
have a working command line with the -u and -p in it they could
share?
If I were to do that...
Copy a *.cmd (give it a valid name) to each of the machines - whatever
location you desire. The contents of that *.cmd file could be something
like:
defrag %systemdrive% -f > \\server\share\%computername%-defrag.txt
Then start that *.cmd file using PSEXEC on each machine and wait for the
\\server\share to populate with the text files. It should tell you what
their status was when starting and what their status was at the end.
The batch/cmd script to do both of those things (assuming you created the
file mentioned above and called it defrag.cmd and the text file you
mentioned was called pclist.txt and everything - including psexec - was in
the same directory when you started) would look like this:
for /f %%u in (pclist.txt) do (
copy /y .\defrag.cmd \\%%u\c$\temp
start psexec \\%%u -u "USERwRIGHTS" -p "%1" c:\temp\defrag.cmd
)
Let's say it was called "RemDefrag.cmd", you would start it with a command
line:
RemDefrag USERwRIGHTS-Password
Then it would parse through your pclist.txt, copy the defrag.cmd file to the
temp directory on each machine (assuming it existed) and then it would use
PSEXEC to start the defrag.cmd on each computer as "USERwRIGHTS" using the
password you provided. It would also write a text file unique to each
computername to a server location for you to peruse at your leisure
now/later.
In any case - there's a simple/built-in way.