Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How to call a powershell script only after an unscheduled outage

Posted on 2013-11-01
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Accepted Solution

alicain earned 2000 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

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

604 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