1

I'm trying to execute a pipe on a remote server by using psexec.

The command that I'm trying to execute is

psexec \\servername DSQUERY USER -name *userpart* | DSGET USER -samid -display

Currently, the | pipe symbol get executed locally which is not what is wanted (since dsget does not exist on my machine).

I tried to use quote around the whole command

psexec \\servername "DSQUERY USER -name *userpart* | DSGET USER -samid -display"

but that resulted in psexec trying to run that whole quoted sentence as one executable, which obviously does not exist.

How can I pass a pipe symbol to the remote server so that it can execute it?

1 Answers1

3

Two possible suggestions come to mind: try to escape the pipe character with a caret (ie. ^|) if that doesn't work, you can create a batch file on the remote machine (including the piped command) and execute the batch file using psexec.

cyberx86
  • 20,805
  • 1
  • 62
  • 81
  • Using a pipe did not work with the error that DSGET is not an argument of DSQUERY. Of course creating a batch file will work, but I feel unsatisfied. Though I give you +1 for telling me how to escape a character in the command prompt. – Pierre-Alain Vigeant Jul 06 '11 at 12:18