![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | redirection operators as syntactic suger Bruce Payette has written myScript > file.txt is just syntactic sugar for myScript | out-file -path file.txt What would be the equivalent PowerShell statements for the other output redirection operators? Quote: Quote: >> 2>&1 - Larry Weiss |
My System Specs![]() |
| | #2 (permalink) |
| | Re: redirection operators as syntactic suger Hi Larry, Those are implemented in PowerShell as is. See: Get-Help about_redirection Or the rather better help file from 2.0: http://technet.microsoft.com/en-us/l.../dd315283.aspx Chris |
My System Specs![]() |
| | #3 (permalink) |
| | Re: redirection operators as syntactic suger Yeah, as Chris said, all of those are built-in to PowerShell and work just as expected. I've been wracking my brain trying to think of a out-file equivalent for the others .... 1) myScript > file.txt myScript | Out-File file.txt 2) myScript >> file.txt myScript | Out-File file.txt -Append Sadly, although they implemented the 2> and 2>& operators, and ADDED "warning" and "verbose" and "debug" output pipes .... they didn't add any redirection operators for the new pipes, nor did they add anything beyond those 2> and 2>& for controlling the output of those... Until PowerShell 2.0 In 2.0, if you have CmdletBinding you can use variable redirection for the Warning and Error pipes, but not Verbose or Debug. -WarningVariable $outWarning -ErrorVariable $outError So basically, if myScript.ps1 had a first line: [CmdletBinding()] You could do all sorts of variations on this: myScript -OutVariable +output -ErrorVariable +output Out-File file.txt -InputObject $output -- Joel Larry__Weiss wrote: Quote: > Bruce Payette has written > > myScript > file.txt > is just syntactic sugar for > myScript | out-file -path file.txt > > What would be the equivalent PowerShell statements for the other > output redirection operators? > Quote: Quote: > >> > 2>&1 > > - Larry Weiss |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Powershell Operators | PowerShell | |||
| CTP2 comparison operators | PowerShell | |||
| Subexpressions and Unary Operators | PowerShell | |||
| ansi versus unicode output with redirection operators? | PowerShell | |||
| Bit Operators | PowerShell | |||