View Single Post
Old 12-11-2006   #4 (permalink)
Keith Hill [MVP]


 
 

Re: How do I redirect for a session or code block?

"cccstar" <cccstar@discussions.microsoft.com> wrote in message
news:509F931F-13F7-4FC4-AF91-BCC9E8E7E170@microsoft.com...
> Thanks for the help but I am still unsure of how to set the text that
> would
> otherwise appear in red on the PS console to output log file. I wanted to
> merge the error and success output text streams for the current session or
> code block.
> Is this the best I can do?
>
> For example if I placed this command in a file ps_code_file.ps1
> Set-Location x:nosuchdirectory -ErrorVariable xxbugs >> myscriptlog.txt
> $xxbugs >> myscriptlog.txt
>
>
> How can I get the


function foo([int]$num) { "hi";1/$num }

foo 0 > foo.txt 2>&1

HTH
--
Keith


My System SpecsSystem Spec