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

Mario2286 421 Reputation points

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


and the results i get is as below

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


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,784 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,891 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vaibhav Chaudhari 38,011 Reputation points

    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

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 38,831 Reputation points

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

    Export-CSV C:\shell\dmsDB_history2.csv -NoTypeInfo
    0 comments No comments