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

In powershell (2.0) the following works nice and fine: cmd /c echo "hello" | select-string hello

Outputs "hello".

When running this in remoting mode, text is not printed:

Invoke-Command -ComputerName myserver -Credential { cmd /c echo "hello" | select-string hello }

Why, and how do I grep text of commands (exefiles) in remoting mode? (windows7 on client, 2008r2 on server. Commands can run fine, ports are open, etc)

share|improve this question

Don't you want to do:

Invoke-Command -ComputerName localhost { cmd /c echo "hello"} | select-string "hello"
share|improve this answer
No, the actual script block which is executed on the remote server is much larger than this example, and from one single of the commands which are executed I want to minimize it's console output. – SomeDude123 Apr 20 '12 at 5:08

The output of Select-String is not a string, but a MatchInfo, which can't be returned over the Invoke-Command connection.

Simply pipe the results of Select-String to Out-String, and you will get your output~:

Invoke-Command -ComputerName myserver -Credential 
    { cmd /c echo "hello" | select-string hello | out-string }
share|improve this answer

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.