How to call a powershell script only after an unscheduled outage

Posted on 2013-11-01
Last Modified: 2013-11-09
I want to be notified when a machine has had an unscheduled outage, without scanning the event log everytime the machine is restarted.  Windows knows when it has had an unscheduled outage an I'd like to tap into that to kick off the powershell script.  

I don't want to scan the events log because the machine may have had an unscheduled outage earlier in the day and then I would receive a false positive the rest of the day.

Question by:c7c4c7
  • 3
  • 2

Accepted Solution

alicain earned 500 total points
ID: 39618645

You can achive this by creating an alert based on the unexpected shutdown event that is raised.

This is done in the event viewer.  You do not mention which OS this is for and it is slightly different but broadly the same between versions of Windows.

On Win 7 for example, open computer manager, event log and look in the right hand pane for "Attach a task to this log" and follow the wizzard, it's fairly straightforward but shout if you need further assistance and which OS it is for.


Author Comment

ID: 39619268
The Os is mainly Win 7 eventually it will include 8 .  

The reason I don't want to include the Event log is that I will be notified by Text Message when the system comes up.  By including it in the event log I will receive a txt message 1st for a legitimate unscheduled shutdown and then again each time the machine is restarted during the day.  It will require a lot of unnecessary work.


Expert Comment

ID: 39621038
I've been pondering this, and how about attaching the powershell script to the event as previosuly discussed and then put logic into the script to determine if an email is to be sent?
e.g. If time event was raised between 9am and 5pm, do nothing, else, send an alert?

Author Comment

ID: 39622644
I will play with this idea and see what I can come up with.  I will get back to you

Author Closing Comment

ID: 39636104
Its working out pretty good, no false positives.  Thanks for the help

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (, we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Synchronize a new Active Directory domain with an existing Office 365 tenant
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now