I have a script call \"a.ps1\":
write-host \"hello host\"
\"output object\"
I want to call the script and obtain the output object, but I a
The output object i.e. "output object
" is output to standard output
. So I don't think you want to suppress standard output. If you don't want anything printed to the console don't use Write-Host
as that bypasses all streams (stdout, stderr, warning, verbose, debug) and displays directly to the host. There is currently no easy mechanism I'm aware of to redirect host output.
BTW why do you need to write "hello host" to the console if you don't want to see it displayed later?