Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Powershell Script - How to find Event Log entries for IO problems that could cause database corruption

05 February,2016 by Tom Collins

Questions: I want a Powershell Script to report on Windows Event Log entries which may
indicate there are IO problems. I'd like to find storage device hardware failures, firmware and device driver problems.
My aim is to run a daily report which will identify these messages and report them to the various teams supporting these devices.


Answer: Running a daily report to identify certain error messages is good practise. There are specific error meesages which
suggest there may be hardware,storage , firmware or device driver problems.
Using Powershell Get-WinEvent it is easy to return entries from the appropriate event Logs.

There are all types of Windows events which suit your requirements. In this example, I'll return
Event ID 9 The device, <device name>, did not respond within the timeout period
Event ID 11 The driver detected a controller error on <device>
Event ID 15 The device, <device>, is not ready for access yet
Event ID 50 {Delayed Write Failed} Windows was unable to save all the data for the file. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere
Event ID 1066 Cluster disk resource Disk <x> : is corrupt. Running ChkDsk /F to repair problems.

There are many more, but these will get you started.

Here is an example Powershell script. This script scans the Windows System Log, from start time and returns entries for event ID = the range specifies

 

Get-WinEvent -FilterHashTable @{ LogName = "System"; StartTime ="05/02/16"; ID = 9,11,15,50,1066}

 
Once you've returned the information , there's all sorts of display and distribution options. The first thing to think about is how to incorporate these details into your daily reporting schedule.

One method is to add the output to the daily health check reports or as part of the SQL Server - Powershell and SQL Error Logs   report.  There's great potential in trying to correlate between SQL Server Error logs and Windows Event log entries.

Once you generate the report either place it into a database or  Send email from Powershell with attachment

 

 

Powershell to HTML - SQL Server DBA

SQL Server - Powershell and Failed Logon attempts - SQL Server DBA

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Powershell Script - How to find Event Log entries for IO problems that could cause database corruption


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer