Last active
November 15, 2024 23:26
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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