I have everything in place at least I think so. I want to email myself the output of a Get-WmiObject win32 command. example:
$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"
I have tried the following:
$body = (
Write-Host "Computer Info:" -Message $PCinfo
) -join "`r`n"
Write-Verbose -Message $body
That returns the error: "Cannot validate argument on parameter 'Body'. The argument is null or empty."
Any direction, advice, or examples would be appreciated. Thanks