Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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 6 '11 at 12:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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