至少我认为我已经准备好了一切。我想通过电子邮件向自己发送 Get-WmiObject win32 命令的输出。例子:
$OS = "."
(Get-WmiObject Win32_OperatingSystem).Name |Out-String
$secpasswd = ConvertTo-SecureString "mypassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential
("support@myemail.com", $secpasswd)
Send-MailMessage -To "support@myemail.com" -SmtpServer
"smtp.office365.com" -Credential $mycreds -UseSsl "Backup Notification" -
Body $body -From "support@myemail.com"
我尝试了以下方法:
$body = (
Write-Host "Computer Info:" -Message $PCinfo
) -join "`r`n"
Write-Verbose -Message $body
这将返回错误:“无法验证参数 'Body' 上的参数。参数为空或空。”
任何方向、建议或示例将不胜感激。谢谢