How can I configure Windows Server 2019 to email system notifications

Kevin Buchs 1 Reputation point
2021-07-27T19:39:39.593+00:00

I've never done this on any Windows Server version previously. So, I found this https://learn.microsoft.com/en-us/windows-server/storage/fsrm/configure-email-notifications . Seems easy enough, but, alas, is not supported on Windows Server 2019 (I guess because I am not configuring a File Server). I've got a remote SMTP server (everything on AWS) and just want the quick and dirty configuration. This is the only Windows server I manage, so I am not interested in any high overhead tools like System Center, etc. Thanks!

Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Hil 106 Reputation points
    2021-07-27T22:10:54.897+00:00

    If Send-MailMessage is a problem try "[System.Web.Mail.SmtpMail]::Send($mail)"

    Here is a script I wrote using the above command to send email using Gmail

    $SendingServer = "smtp.gmail.com"
    $FromAddress = "******@gmail.com"
    $ToAddress = "******@gmail.com"
    $SmtpPort = "465"
    
    $GmailPass = Get-Content "c:\agmail.txt" | ConvertTo-SecureString
    $Cred_Gmail = New-Object System.Management.Automation.PsCredential($FromAddress,$GmailPass)
    
          $subject = "checking the connection" 
          $body = "this is awesome" 
    
    
        # Create a new mail with the appropriate server settigns
    [System.Reflection.Assembly]::LoadWithPartialName("System.Web") > $null
        $mail = New-Object System.Web.Mail.MailMessage
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", $SendingServer)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", $SmtpPort)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", $FromAddress)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpemailaddress", $FromAddress)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", $FromAddress)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", $Cred_Gmail.GetNetworkCredential().password)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", $true)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
        $mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 20)
    
        # Set up the mail message fields
        $mail.From = $FromAddress
        $mail.To = $ToAddress
        $mail.Subject = $subject
        $mail.Body = $body
    
    [System.Web.Mail.SmtpMail]::Send($mail)
    
    2 people found this answer helpful.
    0 comments No comments

  2. Anonymous
    2021-07-27T20:20:22.787+00:00

    You can follow along here to set that up.
    https://www.ryadel.com/en/event-viewer-send-notification-e-mail-messages-with-powershell/

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.

  3. Anonymous
    2021-07-27T21:26:50.577+00:00

    Maybe AWS provides notifications for their virtual machines health.

    --please don't forget to upvote and Accept as answer if the reply is helpful--


  4. Anonymous
    2021-07-27T22:10:55.03+00:00

    Maybe the task can call a vbscript using CDO.Message
    https://social.technet.microsoft.com/wiki/contents/articles/54007.vbscript-send-email-with-attachment.aspx

    --please don't forget to upvote and Accept as answer if the reply is helpful--


  5. Anonymous
    2021-07-28T12:37:44.14+00:00

    Just checking if there's any progress or updates?

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.