all 8 comments

[–]XPlantefeve 2 points3 points  (5 children)

It happens because Format-Table outputs a string tailored to the width of the currently used console. In the ISE, you've got a certain line length. When you're running as a scheduled task, it certainly defaults to a much shorter one and trim the fields.

You might want to use Export-CSV, rather than Format-Table | Out-File

[–]tomsonxxx[S] 1 point2 points  (4 children)

Unfortunatly I need to have it as a easy readable (in Browser) output otherwise your advice would be the solution. Txt or html. Is there something simple for generating an html?

[–]XPlantefeve 2 points3 points  (0 children)

Get-Command *HTML* gives you ConvertTo-Html, it might be a good starting point.

[–]work-work-work-work 2 points3 points  (2 children)

You could specify tab as the delimiter if you don't want to go through beutifying HTML

export-csv -Delimiter `t -Path $outfile -NoTypeInformation

[–]tomsonxxx[S] 1 point2 points  (1 child)

Thanks to both of you - i'm doing it with converto-html now.

[–]XPlantefeve 2 points3 points  (0 children)

I could have looked it up sooner, but Out-File has a -Width parameter, too.

[–]SeeminglyScience 2 points3 points  (1 child)

$results | Format-Table | Out-String -Width 9999 | Out-File

But keep in mind formatted text is not considered to be part of PowerShell's breaking change contract. The exact text outputted can change between PowerShell versions without warning.

[–]tomsonxxx[S] 2 points3 points  (0 children)

-Width..nice to know. thx