views:

116

answers:

1
+1  Q: 

Powershell output

I'm having a little issue with controlling output in ps. Here's the line of code in question;

$result|sort-object cn  | format-table -wrap -autosize

If I append

| out-file $logfile

the last column of my output is truncated. Now I know that if I changed the width of my console session and run the script again, my output is fine, but there must be a better way of doing this? I also attempted to use add-content but I think I must be missing something as the expression isn't being evalulated correctly and I just get a series of references to system-object in my logfile.

+2  A: 

You can use the -width parameter for the out-file cmdlet. You might try out-file -width 500 so nothing gets truncated.

Andy Schneider