Skip to content

Instantly share code, notes, and snippets.

@macna
Last active February 19, 2024 23:30
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save macna/3bf3d32c475473b0d757 to your computer and use it in GitHub Desktop.
This PowerShell script sends an email notification when a server reboots. The script simply sends an email message, and is to be used on a scheduled task that is triggered at system startup.
# Get the server name
$hostName = hostname
# Define the email address to send notifications to
$toAddress = "someone@contoso.com"
# Send the notification
Send-MailMessage -To $toAddress -From "$hostName@contoso.com" -SmtpServer smtp.contoso.com -Subject "$hostName - Server Reboot" -Body "The server $hostName has rebooted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment