Say I run this:
$HOME_DATABASE = 'mydb'
$params = @{
'Database' = $HOME_DATABASE
'ServerInstance' = 'mydb'
'Username' = 'myuser'
'Password' = 'mypass'
'Query' = 'select * from sometable'
}
$queryresults = Invoke-Sqlcmd @params
I want the output to look like:
Name Date Number of Records 95th Percentile 99.5th Percentile 100th Percentile
---- ---- ----------------- --------------- ----------------- ----------------
asdf 2022-10-02 00:00:00.000 1234 5678 9012 12345
where what's separating the fields is a tab.
I tried this, but it doesn't include the hyphen/dash line.
$queryresults |ConvertTo-Csv -NoTypeInformation -delimiter "$query_result_separator" | `
ForEach-Object {$_ -Replace('"','')} | `
Out-file c:\temp\$($query_attachment_filename) -fo -en ascii
Somebody else said to export-csv, then go back and replace the quotes in the file. Is there a better way?