44 lines
1.7 KiB
PowerShell
44 lines
1.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Check the status of the fysical drives (if any) on the system
|
|
|
|
.DESCRIPTION
|
|
This script will check if there are any error on the disks and will let you know if you need to investigate any errors,
|
|
This script should be deployed as a Check Script.
|
|
|
|
By default the script will check upto 1 day back in the log,
|
|
If you adjust the $Timespan parameter you can extend this by more days.
|
|
|
|
.OUTPUTS
|
|
This script will report back if it found any of the event logs on the machine with the message of that log entry.
|
|
|
|
Errorcodes:
|
|
0 - All OK
|
|
1 - Disk errors detected please investigate
|
|
|
|
.EXAMPLE
|
|
Win - Disk drive health.ps1
|
|
|
|
.NOTES
|
|
Source: Tactical RMM repository
|
|
|
|
.CHANGELOG
|
|
24-06-2022 - Copied from TRMM repo, tweaked for my own environment.
|
|
#>
|
|
|
|
#region Parameters, functions and global variables
|
|
$ErrorActionPreference = 'silentlycontinue'
|
|
$TimeSpan = (Get-Date) - (New-TimeSpan -Day 1)
|
|
#endregion
|
|
#region script
|
|
if (Get-WinEvent -FilterHashtable @{LogName = 'system'; ID = '11', '9', '15', '52', '129', '7', '98'; Level = 2, 3; ProviderName = '*disk*', '*storsvc*', '*ntfs*'; StartTime = $TimeSpan } -MaxEvents 10 | Where-Object -Property Message -Match Volume*) {
|
|
Write-Output "Disk errors detected please investigate"
|
|
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 {
|
|
Write-Output "Disks are Healthy"
|
|
exit 0
|
|
}
|
|
Exit $LASTEXITCODE
|
|
#endregion |