question

Mario2286-5314 avatar image
0 Votes"
Mario2286-5314 asked ·

Powershell output file in txt file don't have all columns

I was executing this Powershell command below to get DB backup history

$SQLServer = Get-Content -Path "C:\shell\cdms.txt"
Invoke-DbaQuery -sqlinstance $SQLServer -File "C:\shell\sqladmin.sql"| Out-File C:\shell\dmsDB_history2.txt

and this is the sql query

74679-backup-based-on-date-history-good.txt


and the results i get is as below
74680-image.png


supposed to be 7 columns but I can see only three columns and then 3 dot as I highlighted in yellow in output notepad file.

Please advice me how get all 7 columns in output file

It must have this 7 column below

74781-image.png


sql-server-generalwindows-server-powershell
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VaibhavChaudhari avatar image
0 Votes"
VaibhavChaudhari answered ·

Try adding width in the end

Invoke-DbaQuery -sqlinstance $SQLServer -File "C:\shell\sqladmin.sql"| Out-File C:\shell\dmsDB_history2.txt -width 5000


Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

Instead of using "Out-File" why not use a CSV?

 Export-CSV C:\shell\dmsDB_history2.csv -NoTypeInfo
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.