18

I'm trying to capture the output of the remote process from psexec (i.e. not psexec's own output). So, for example I could run "ipconfig" and print the output to a log file.

I have tried:

psexec \\myserver ipconfig > output.log
psexec \\myserver ipconfig >> output.log
psexec \\myserver ipconfig 2> output.log
psexec \\myserver ipconfig > output.log 2>&1

The last just gives the psexec output.

I'n not sure what the differences are between all of these, but I've seen them suggested in my hunt for the answer elsewhere.

Can anybody give me an example command line that will capture the output of ipconfig to a file??

Edit 1: I want the log file to be saved on the local machine, not the remote one.

Edit 2:

Here is what I get from running "psexec \\myserver ipconfig":

C:\TempDll>psexec \\myserver ipconfig

PsExec v1.95 - Execute processes remotely
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com


ipconfig exited on myserver with error code 0.

C:\TempDll>
  • Do you want the log saved on the local or remote machine? – Alex J Jun 29 '09 at 8:03
  • 1
    Hm, "psexec \\myserver ipconfig > output.log" works on my machine – splattne Jun 29 '09 at 9:03
3

Possibly a bug in PsExec in v1.95?

I have v1.94 and get the output fine but i've just downloaded the latest copy and get the same problems as yourself.

EDIT:

PsExec on my public SkyDrive

  • D'oh!! Could you link a copy of 1.94 on here? I cannot seem to find a copy online anywhere. Everytime I download "v1.94" it actually gives me 1.95 :( – joshcomley Jun 29 '09 at 9:59
  • FYI: It's at v1.96 as of 06/29. – Chris Jul 16 '09 at 12:01
3

Hope this can help someone. I was able to run PSExec with the following command on Windows 10 and a remote Windows 10 instance.

psexec \\ipaddress cmd /c "ipconfig>c:\Tools\output.txt"

Command

  • This worked for me on Windows 10 LTSB. Great suggestion. psexec -s -d "cmd /C ipconfig" > outputfile.txt 2>&1 – TheIncorrigible1 Feb 22 '18 at 16:52
1

Just be careful in which folder do you want to save the file output.log.

Store output.log locally:
psexec \\serverIP ipconfig > c:\output.log

Store output.log on a remote machine:
psexec \\serverIP ipconfig > \\ipaddress\c$\output.log

psexec ... > output.log will overwrite file output.log in case it exists.
psexec ... >> output.log will append the output at the end.

You can also run psexec \\serverIP cmd, change your directory on a remote machine and simply run ipconfig > output.log

  • Thanks Roy, but all I get is a blank output.log file, the same as with the examples I tried above :( – joshcomley Jun 29 '09 at 8:29
  • Do yout get anything if you run psexec \\serverip ipconfig ? – Jindrich Jun 29 '09 at 8:39
  • @Roy - I've updated my question with the response to that at the bottom. Perhaps something deeper is going wrong here.. – joshcomley Jun 29 '09 at 8:43
1

Only way I found is to create a quick bat script:

psexec %1 %2

Or replace %2 with the command/args you want.

Run with remote-psexec

\\systemname systeminfo | more
1

If you want to save output locally on remote machine. you may use below command. psexec \myserver cmd /c "ipconfig >output.log"

If you want to redirect output from remote machine to hosted machine. you may use below command psexec \myserver cmd /c "ipconfig>\localmachine\location\output.log"

0

I had the same issue and had to tell PSEXEC to run as an admin user on the remote machine:

psexec \\serverIP -u DOMAINNAME\username -p PaSsWoRd ipconfig /all > c:\output.log
0

The only time you need to specify a username and password with PSExec is if you need to pull data from a network share. I strongly recommend against it though, as the password is sent in cleartext, meaning anyone listening to traffic now has your username and password.

0

I found that using a FQDN for the servername solved my issue.

  • That's nice, but there's no indication that this would have anything to do with the OP's case. – HopelessN00b Nov 9 '12 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.