lining up columns

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5482

    by jgk-ps at 2013-01-29 10:42:22

    im probably missing something totally obvious but i cant figure this out out

    basically im running this command:

    Send-MailMessage -To dude@example.com -From foo@example.com -Subject "funky columns" -Body "$(get-process | out-string)" -SmtpServer mail.example.com

    and the in the email i get, the columns don't line up. its boarderline unreadable.

    by DonJ at 2013-01-29 10:59:02

    That's because PowerShell assumes you're using a monospaced font. It isn't intended to provide robust formatting, especially for proportional fonts.

    Instead of Out-String, use ConvertTo-HTML. Then add the -BodyAsHTML (I'm not in front of a shell – that's probably the wrong parameter name, but there's something similar). That'll give you an HTML table, which will leave everything lined up.

    by jgk-ps at 2013-01-29 11:06:27

    lo and behold, it was totally obvious in hindsight

    thanks don

You must be logged in to reply to this topic.