Reputation: 69
Using Invoke-SQLCMD and running a saved query, Is there a way to see the output as a table? Currently, All output is printed sequentially, such as Name newline state newline is_encrypted for each item returned from the query rather than a row-column table where name, state, is_encrypted, etc. are the column headers.
The end goal is to output all the results of the query into a text or excel file.
Upvotes: 0
Views: 159
Reputation: 1377
Try this:
Invoke-Sqlcmd -query $sql | Export-Csv -Path c:\temp\excelfile.csv -NoTypeInformation
Upvotes: 2