2
我有一个来自robocopy的备份日志文件,并希望从该文件中取出最后一行并将其作为电子邮件正文发送。 日志例如:将文本数组发送到电子邮件正文
Total Copied Skipped Mismatch FAILED Extras
Dirs : 85262 85257 1 0 4 0
Files : 637048 637047 0 0 1 0
Bytes :1558.929 g1558.929 g 0 0 165 0
Times : 19:30:49 19:01:06 0:00:00 0:29:43
Speed : 24448224 Bytes/sec.
Speed : 1398.938 MegaBytes/min.
Ended : Wed Sep 21 15:42:01 2011
Script代码:
$report2_tail = Get-Content .\backup2.log)[-12 .. -1]
$encoding = [System.Text.Encoding]::UTF8
Send-mailmessage -Smtpserver smtp.server.address -encoding $encoding -from "Backup-Replication<[email protected]>" -to "[email protected]" -subject "End of Replication Report" -body "
backup Replication Report
------------------------------------------------------------
$report2_tail
"
脚本工作正常,但消息体是一条线,看起来像这样:
Total Copied Skipped Mismatch FAILED Extras Dirs : 85262 85257 1 0 4 0 Files : 637048 637047 0 0 1 0 Bytes :1558.929 g1558.929 g 0 0 165 0 Times : 19:30:49 19:01:06 0:00:00 0:29:43 Speed : 24448224 Bytes/sec. Speed : 1398.938 MegaBytes/min. Ended : Wed Sep 21 15:42:01 2011
什么是一个最好的方法解决这个问题 ? 问候 马辛