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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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"
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"
ASKER
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?