0
我需要帮助将一个哈希表输出到电子邮件的正文中。在Powershell中转换Hashtable
$computer = "adwte998"
$err = "This is the error"
$td = Get-Date
$table = @{
Workstation = $computer
Error = $err
Time = $td
}
send-mailmessage -to "[email protected]" -from "Automated Reboot<[email protected]>" -subject "E-Mail HashTable Test" -body ($table | Out-String) -smtpserver smtpserver.email.com
消息体看起来像它应该,如果我只是返回$表
我会非常喜欢表转换为看起来像一个CSV用正确的列标题,但我不格式不想通过电子邮件将其作为附件发送。
有谁知道我可以怎么做呢?我甚至会考虑将其转换为HTML,以便在电子邮件中看起来不错。
好吧,这解决了如果我要输出到屏幕上,但我想现在将其转换为HTML表的格式所以我可以在Send-MailMessage中使用-BodyAsHtml。我会怎么做? – Patrick
添加了转换为html的示例 – mjolinor