by jgk-ps at 2013-01-29 10:42:22
im probably missing something totally obvious but i cant figure this out outby DonJ at 2013-01-29 10:59:02
basically im running this command:
Send-MailMessage -To firstname.lastname@example.org -From email@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.
That’s because PowerShell assumes you’re using a monospaced font. It isn’t intended to provide robust formatting, especially for proportional fonts.by jgk-ps at 2013-01-29 11:06:27
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.
lo and behold, it was totally obvious in hindsight