If you move the format-table from where you had it to after $data in the last line, you might get what you seek. But honestly, its rare that you should use a format-* in a script anyway as it leaves you with nothing but a boring string (instead of glorious objects). You might get more use out of this by handling presentation of the results outside of the script entirely. Pipe the script itself to export-csv, or format-table depending upon your use. I think the problem might be that you don't yet understand that what you're asking for (table of text in a file) is not really what you're looking for - from a certain point of view, anyway.