PowerShell Send Email in one line command

  Powershell

Powerful one liner to send an email with PowerShell.  Useful in scheduled tasks to send status, or additional info. The use of environment variables is totally optional, but make a fine subject line when you want to know from which server it came from !

Suggestions on improvements are welcome, please leave a comment !

send-mailmessage -to "<a href="mailto:[email protected]" data-mce-href="mailto:[email protected]">[email protected]</a>" -from "$env:[email protected]" -subject "WARNING - $env:computername.$env:userdnsdomain Rebooted" -BODY "WARNING - $env:computername.$env:userdnsdomain Rebooted" -smtpServer mail.domain.com

LEAVE A COMMENT