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:my.user@domain.com" data-mce-href="mailto:my.user@domain.com">my.user@domain.com</a>" -from "$env:computername@domain.com" -subject "WARNING - $env:computername.$env:userdnsdomain Rebooted" -BODY "WARNING - $env:computername.$env:userdnsdomain Rebooted" -smtpServer mail.domain.com

Leave a comment