![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | BUG: Redirecting function contents to a file truncates function lines at the width of the console In my profile.ps1 file, I have various functions with line widths greater than 80 columns. My console is 80 columns. If I use the following: get-content function:foo >filename The function body will be written to the filename, but the lines will be wrapped at the width of the console. This of course results in invalid code when the end of a comment is on its own line, or a variable name gets cut off in the middle. I've had to do the following: (get-content function:foo).ToString() >filename Which works as expected. I imagine there are probably other instances of the console formatting being applied to things that are being sent to a text file. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Redirecting function contents to a file truncates function lines at the width of the console The redirector operator uses out-file underneath. Try this: gc function:foo | out-file filename -width 120 There are other parameters on out-file that allow you to controls things like encoding, appending, etc. -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Redirecting function contents to a file truncates function linesat the width of the console Keith Hill [MVP] wrote: > The redirector operator uses out-file underneath. Try this: > > gc function:foo | out-file filename -width 120 > > There are other parameters on out-file that allow you to controls things > like encoding, appending, etc. Hmm, thanks, good to know. But it shouldn't be wrapping lines in output files by default, I don't think. And how could I send the error stream to a file without it wrapping? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| function to delete a function | PowerShell | |||
| File.Exists Function | .NET General | |||
| function return values, console output | PowerShell | |||
| How to - named function in script file | PowerShell | |||