Formatting Send-Mailmessage output without HTML

Hi there!

I wrote a script which gives me an overview of the existing databases and the free space of it.

It's all saved in an array and looks like this:

Nr. DBName                           DBSize(MB) DBFree(MB) LogSize(MB) LogFree(MB)
--- ------                           ---------- ---------- ----------- -----------
  1 AdventureWorks2012                      221 31(14%)             75 71(95%)    

  

I want this to be sent to an email address, but unfortunately the format of it is keeping me upset, because it looks like this:

Nr. DBName                           DBSize(MB) DBFree(MB) LogSize(MB) LogFree(MB)

--- ------                           ---------- ---------- ----------- -----------

  1 AdventureWorks2012                      221 31(14%)             75 71(95%)    

How can I edit the format of it ? Am I even able to add `t `r to the $body variable ?

I send it with following parameters:

$Body = $Body1 | Out-String
$Encoding = [System.Text.Encoding]::UTF8
Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer $SMTP -Encoding $Encoding

So my question is: Is there any opportunity to format the array without formatting with html?
It's pretty hard do determine the values when it's more than 5 because the columns aren't in line.



July 27th, 2015 9:14am

$Body = $dbl | Select-Object DBName,'DBSize(MB)','DBFree(MB)','LogSize(MB)','LogFree(MB)' | Sort-Object DBname | ConvertTo-Html | Out-String

That's the solution - it now finally works!
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2015 7:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics