【发布时间】:2018-11-01 16:42:34
【问题描述】:
See attached photo (link) of Output in PowerShell and Outlook.
我正在尝试通过电子邮件发送输出,但无法让脚本将输出放入电子邮件正文。它不是抓取介于所需阈值(70 天)之间的服务名称和到期日期,而是抓取 CSV 中的所有内容(例如,查看 2022 年到期的服务)并将其放入电子邮件正文中。
我的问题是我如何让它仅通过电子邮件发送我在 PowerShell 中提取的信息(在指定阈值日期之间的信息)?
有点新的脚本,谢谢! :)
$now=get-date
$cert = Import-Csv C:\Users\userID\Desktop\Certificate_CSV2.csv
$threshold = 70
$deadline = (Get-Date).AddDays($threshold)
$cert | Select-Object "Service Name", "Certificate Expiration Date" | Where-Object {$_."Certificate Expiration Date" -as [datetime] -le $deadline}
Send-mailMessage -to "SentTo@email.com" -subject "test message 8" -from "SentTo@email.com" -body ($cert | Out-String) -SmtpServer pobox.email.com
【问题讨论】:
标签: powershell email output send