Alan's Blog

"Yeah. I wrote a script that will do that."

Get Downtime Using PowerShell

Posted on February 25th, 2017

I have been having problem with a computer with random reboots, and hanging on restart.  I wanted to know how long the computer had been unavailable.   I decided to use System Event ID 12 as the startup event for the purposes of my calculations.  The script takes these steps: 1) connect to the remote system and get the oldest event from the System Log.  Use this as the earliest start date for queries.  2) Collect all the startup events from user selected date.  3) For each startup event, collect the event immediately previous by record number.  4) Calculate the difference.

Get-DownTime.ps1 is the advanced function which gets the information.  It is the first function I have written which includes A Dot Source Reminder for Advanced Functions.

Script Text

Filed under Computing, Functions, PowerShell, Scripting, Windows Administration |

Leave a Reply

You must be logged in to post a comment.

Please Note

All the scripts are saved as .txt files. Newer files have a "View Script" button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use "Save Target As". Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with Version 3 or 4.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient. It is pretty easy to figure out my email address from the scripts, and you are welcome to contact me that way.

Site Search

Categories

Archives

SQL Site

Bad Behavior has blocked 169 access attempts in the last 7 days.