Link to home
Start Free TrialLog in
Avatar of kam_uk
kam_uk

asked on

Full view in export of format-table

I want to run a Powershell command to export some information into a table.

get---xxx | get-yyyy| ft name, attribute1 > c:\info.csv

Unfortunately, the export seems to be cropped. I've tried -autosize, but then I get a message saying that yyyy was too large to fit into the display.

Since I am exporting to a CSV, does anyone know how I can force Powershell to export ALL the info?
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kam_uk
kam_uk

ASKER

Thanks, the reason I wanted format table is because I wanted to see it in table format, with each entry on a different line...can I still do this with export-csv? I thought the ">" meant the same as export-csv?

Secondly, I'd like to sort by one of the attributes (attribute1), e.g. alphabetically lowest to highest, do you know how I would do this?
get---xxx | get-yyyy| sort-object attribute1 | select-object name, attribute1 | export-csv c:\info.csv

And no, format-table >    is not the same as export-csv. The latter formats the output appropriate for CSV, while format-table is used to display like in a table - on the screen, but not in a file.
Then you can do this, but not a CSV, but a simple text file:
get---xxx | get-yyyy| sort-object attribute1 | select-object name, attribute1 | out-file c:\info.txt

You can even override the width by:
get---xxx | get-yyyy| sort-object attribute1 | select-object name, attribute1 | out-file c:\info.txt -width 800



Why not using export-csv, soostibi?
You said, that you want to see the same in the file as in the screen. CSV is a different format, it organizes data by commas (Comma Separated Values), so it will never be like the data on the screen.

You might change the separator to TABs, it will be more similar:

get---xxx | get-yyyy| sort-object attribute1 | select-object name, attribute1 | export-csv c:\info.csv -delimiter "`t"