2021-01-10 17:33:48 +00:00
|
|
|
# Checks local disks for errors reported in event viewer within the last 24 hours
|
|
|
|
|
|
|
|
$ErrorActionPreference= 'silentlycontinue'
|
|
|
|
$TimeSpan = (Get-Date) - (New-TimeSpan -Day 1)
|
|
|
|
if (Get-WinEvent -FilterHashtable @{LogName='system';ID='11','9','15','52','129','7','98';Level=2,3;ProviderName='*disk*','*storsvc*','*ntfs*';StartTime=$TimeSpan})
|
|
|
|
|
|
|
|
{
|
2021-01-10 17:35:50 +00:00
|
|
|
Write-Output "Disk errors detected please investigate"
|
2021-01-10 17:33:48 +00:00
|
|
|
Get-WinEvent -FilterHashtable @{LogName='system';ID='11','9','15','52','129','7','98';Level=2,3;ProviderName='*disk*','*storsvc*','*ntfs*';StartTime=$TimeSpan}
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2021-01-10 17:35:50 +00:00
|
|
|
Write-Output "Disks are Healthy"
|
2021-01-10 17:33:48 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Exit $LASTEXITCODE
|