Skip to content

Instantly share code, notes, and snippets.

@macna
Last active November 15, 2024 23:26
Show Gist options
  • Save macna/3bf3d32c475473b0d757 to your computer and use it in GitHub Desktop.
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 = "[email protected]"
# Send the notification
Send-MailMessage -To $toAddress -From "[email protected]" -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