1

eIn Powershell, Invoke-sqlcmd is truncating my output at 80 columns

I've tried this code and things are still being truncated at the 80th column

$ans=Invoke-Sqlcmd -ServerInstance $sqlServer -Database $MyDbName -Query $SQLSCRIPT -OutputAs DataTables |Format-Table -Property * -AutoSize | Out-String -Width 4096 | Out-File $FullPathReportFileName

How can I keep it from truncating and looking like this?:

0

1 Answer 1

1

What does the output look like? The way it looks on the screen is kind of an illusion. If you pipe to format-list, or select -expand property, it will probably show the whole thing. You might like this setting:

$formatenumerationlimit = 99

Or increase the size of the window.

Sign up to request clarification or add additional context in comments.

4 Comments

Just added a pic to the question
What version of powershell is it? You can try piping it to ft -autosize, or increasing the width of the window.
So, I ran it with a larger powershell window and it worked fine. It's strange that it's based on the width of the PS window.
$FormatEnumerationLimit, which defaults to 4, determines how many elements of a collection-valued property to display inside a column, which is unrelated to @cashonly's problem. It is worth making it clearer in the answer that increasing the size of the window is what helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.