I have a powershell script that gives some status output via write-output. I am intentionally not using write-host because the output may be captured and writt
Separate the results on the pipeline from the status messages in the console.
E.g., use a function like this in your script:
function write-status( $status ){
$status | write-host -fore green -back red; #send a status msg to the console
$status | write-output; #send a status object down the pipe
}
I would also recommend you use one of the following cmdlets over write-host for outputting status messages from your scripts:
The appearance of these status messages will vary depending on the cmdlet used. In addition, the user can disable specific levels of status using the $(warning|error|verbose|debug)preference variables, or capture specific status messages using the -(warning|error|verbose|debug)variable common cmdlet parameters.