I am trying to read some of bottom lines from my log file and send the content as a table in the email.
Log File:
0 \\Server\Copy\db_materials\TEST\
Total Copied Skipped Mismatch FAILED Extras
Dirs : 508 0 508 0 0 0
Files : 9109 0 9109 0 0 0
Bytes : 1.115 g 0 1.115 g 0 0 0
Times : 0:01:03 0:00:00 0:00:00 0:01:03
Ended : Thursday, March 19, 2020 11:03:22 PM
Powershell Script:
$body= (Get-Content -Path D:\logs\logfile.log -Tail 8 | Out-String) |ConvertFrom-Csv | ConvertTo-html | Set-Content D:\RMSscripts\Sample.html -Encoding UTF8
$EmailFrom = "xyz@abc.com"
$EmailTo = "myemail@abc.com"
$EmailSubject = "Report"
$SMTPServer = "smtp.server.com"
end-MailMessage -Port 25 -SmtpServer $SMTPServer -From $EmailFrom -To $EmailTo -Subject $EmailSubject -Body $body-Bodyashtml;
In the email, the content are pasted as below.
Total Copied Skipped Mismatch FAILED Extras
Dirs : 508 0 508 0 0 0
Files : 9109 0 9109 0 0 0
Bytes : 1.115 g 0 1.115 g 0 0 0
Times : 0:01:03 0:00:00 0:00:00 0:01:03
Ended : Thursday, March 19, 2020 11:03:22 PM
Expected is: Expected report in email
How to convert the raw content into table format?