1

Windows Server 2012 R2 w/ GUI, UPS system

I am setting up my first server. It is a Hyper-V host that will host multiple VM servers. The system is on a UPS.

When the UPS detects an AC power failure, the UPS sends an email via an SMTP mail server located elsewhere, and then performs a graceful server shutdown if power is not restored after a certain period of time. When the power is restored, the host machine BIOS is setup to automatically reboot.

I'd like to get emails from the various servers that they have rebooted after power is restored. My UPS doesn't send emails upon AC restore, but even if it did, that wouldn't tell me the servers were back up. I'd like each server to send an email after it is back online.

What steps/methodologies need to be used to accomplish this? By methodologies I mean to ask if I need to write a script, or is there a built-in tool to accomplish this, etc?

I have the SMTP server info, ports, log in credentials, etc. to send an email, I just don't understand how to make a server do that upon power up, or what the standard/best practice is for such notification to normally be handled.

Thanks.

Alan
  • 1,003
  • 2
  • 20
  • 36
  • 1
    You could find the relevant event in the System event log and create a task to send an email based on that event. – joeqwerty Apr 29 '15 at 16:39
  • So this seemed like a pretty cool idea, but I haven't been able to create a task to do this. Some posts I viewed to create a task suggest you can only use a local email server & when I tried to create a task there was only space for a server; no places for SMTP info like credentials, port, etc. I also noted the task wizard says email is deprecated. I'm commenting here in case I'm missing something, and also if others try this idea. Still, a great idea if it can be worked. Any thoughts? – Alan Apr 29 '15 at 20:06

2 Answers2

1

One of the ways you could accomplish this without writing a Powershell script is with a monitoring service. Do you have any type of monitoring currently setup? Most monitoring services will notify that the server is unreachable and then also send a "all clear" email when the server is back up. A few of the free & open source tools I have used are Zabbix and Nagios. They can work with a agent installed or in agentless mode using SNMP. They are also tools ManageEngine that is free for up to 20 servers monitored. https://www.manageengine.com/free-windows-health-monitor/free-windows-health-monitor-index.html

I think this approach is best because it also gives you the ability to monitor other key metrics ( if they are not already monitored).

Alfonso
  • 101
  • 2
  • I did some poking around on the manage engine website and see the server monitor package you speak of. Will continue to investigate and post back. – Alan Apr 29 '15 at 22:58
0

My suggestion:

On each VM server you create two files:

  1. First; An .eml file. This is a text file which is used as e-mail template. Populate it with the specific system information you want to receive when the specific server is started. The file should start like this:

From: sender@domain.com

To: youremail@yourdomain.com

Subject: System startup server nnn

  1. Secondly; A batch file to copy the .eml file to the pickup folder of your exchange server. The pickup folder is to be found at: “C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\pickup" of your exchange server.

  2. Finally, on each VM server create a task in task scheduler (taskschd.msc) which is triggered on system startup and has an action to run the above batch file.

I used this solution since I was not able to get the e-mail function of system events working. After Exchange finds a .eml file in the pickup folder, it will be sent and removed from the folder. So, for each e-mail you would like to receive, you need to copy an .eml file to the pickup folder.

Hope this helps.

Edit: if you don't have an Exchange server running, my idea of starting a batch file with task scheduler combined with this question https://stackoverflow.com/questions/709635/sending-mail-from-batch-file could give you the desired result as well.

  • You solution seems pretty straightforward to me, but correct me if I'm wrong; I don't have an email server (Exchange) on my local system so I can't implement what you suggest. I was doing a little poking around MSDN and it seems like I can install a SMTP service which is a component of IIS, but I'm not clear on this. I am clear that I need something that will transmit a SMTP packet, but how I set that up I'm not clear on. Any thoughts? – Alan Apr 29 '15 at 22:57
  • Alan, I missed the point that you don't have an exchange server running. I've edited my answer to incorporate this point. – Andre Timmermans Apr 30 '15 at 19:10
  • I now have a good powershell script that successfully sends an email. So I'm through the first part of this. My problem now is getting the script to run when I want it to run. – Alan May 04 '15 at 22:36
  • You can use the taskschd.msc on each vm to create a task which is triggered after booting the system and calls your powershell script. – Andre Timmermans May 07 '15 at 06:03
  • On Server 2012 I was able to use the Policy Editor very nicely to do this. I will be adding a long post to share my journey through what I thought would be simple but was not, for me. But your comment causes me to ask about Event IDs. I read all over how to schedule tasks this way, and did it. But I'm still left with the thought that attaching tasks to Event IDs is not very precise. How does one choose which Event ID to use? I didn't really see an event that says "We're done. Server's up." Is there a list somewhere? Did I miss something? Should I ask this as a different question? – Alan May 07 '15 at 20:09