1

I'm trying to output a table to a file but the text gets cropped in the output file.

$Data.items | Format-Table | Out-File $filename -Width 10000

$Data.items | Format-Table -AutoSize | Out-String -Width 4096 | Out-File $filename -Width 4096

$Data.items | Format-Table -AutoSize | Out-File $filename -Width 4096

$Data.items | Format-Table -AutoSize | Out-File $filename

How should I output the data to the file so it´s not cropped?

The $Data-object is the result from the Azure API to get consumption, example output can be found here: https://learn.microsoft.com/en-us/partner-center/develop/get-invoice-unbilled-consumption-lineitems#response-example-1

Daniel Björk
  • 2,475
  • 1
  • 19
  • 26
  • Perhaps also use parameters `AutoSize` and `Wrap` on Format-Table, or using `Export-Csv` suits your needs better? – Theo Sep 01 '20 at 09:22
  • AutoSize didnt do any difference and I dont want to Wrap the text – Daniel Björk Sep 01 '20 at 09:24
  • @Theo outputing to Csv it not what I would like to do, I want it to be plain text. – Daniel Björk Sep 01 '20 at 09:36
  • `...|Format-Table -AutoSize |Out-String -Width $HugeNumber` works for me. @DanielBjörk can you provide sample input and output? – Mathias R. Jessen Sep 01 '20 at 10:27
  • @MathiasR.Jessen updated my question with a link to an example of the data Im trying to export to a file in raw text. – Daniel Björk Sep 01 '20 at 11:04
  • Unable to reproduce in PowerShell 5.1 with the linked json response. `($json |ConvertFrom-Json).items |Format-Table -AutoSize |Out-String -Width $AnyNumberOver1314` produces a non-cropped table output (although I'd need a significantly wider screen to find that useful) :) – Mathias R. Jessen Sep 01 '20 at 12:54

1 Answers1

0
$Data.items | Format-Table -Property * -AutoSize ` | Out-String -Width 4096 ` | Out-File 'c:\Users\username\Desktop\Notcropped.txt';
חִידָה
  • 259
  • 1
  • 2
  • 14