Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 using a port of a cygwin tool on Windows which writes normal status messages to STRERR. This produces ugly output when run from PowerShell:

PS> dos2unix.exe -n
dos2unix.exe : dos2unix: converting file to file in UNIX format ...
At line:1 char:13
+ dos2unix.exe <<<<  -n
    + CategoryInfo          : NotSpecified: (dos2unix: conve...UNIX format ...:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Is there a better way?

P.S. I intend to post one solution I've found and compare it to answers from others.

share|improve this question
up vote 1 down vote accepted

This is one solution I've found. Please post your answer if you have a better answer (this is intended only for command-line utilities that send status messages to STDERR instead of normal output stream):

PS> $output = dos2unix.exe -n 2>&1
$output.CategoryInfo.TargetName | Out-Default
dos2unix: converting file to file in UNIX format ...
share|improve this answer
It looks fine to me except that | Out-Default is probably unnecessary. – Dennis Williamson Nov 23 '10 at 3:39

No, alas. This ugliness is an by-design feature of Powershell :( If an application prints to standard error (and anything else is listening), then Powershell wraps each line in an obfuscating 'NativeCommandError' object. See for more detail

You could silence the ugly objects, but then you'd lose the useful content too.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .