Select Page
This entry has been published on 2014-05-20 and may be out of date.

Last Updated on 2014-05-20.

For monitoring the health state of common Windows Software RAIDs, I use a script from this site.

Windows Server 2012 / R2 and Windows 8 / 8.1 now offer the usage of Storage Spaces, which are more flexible than the other Windows RAID types.

So I modified the script a bit to read the status of the Storage Pools.

Download it here: storagepoolcheck

…or have a look at the code below.
Please note I have not tested it with Windows Server 2012, it might have another status value than “OK” or “Degraded”, but usually it should be the same.

' Software RAID status check script

Option Explicit

Dim WshShell, oExec
Dim Line, RE0, RE2
Dim Failed

Failed = -1
' Simple variable to display status of all volumes:
' 0 = Healthy
' 2 = Failed
' 3 = Unknown

' Check version of WScript. Has to be >= 5.6 for WScript.Shell.Exec to work
If Wscript.Version < 5.6 Then
Failed = 3
Wscript.StdOut.WriteLine(&quot;UNKNOWN: WScript version < 5.6&quot;)
WScript.Quit(Failed)
End If

Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

' Execute the DISKPART program and grab the output
Set oExec = WshShell.Exec(&quot;%comspec% /C powershell Get-StoragePool&quot;)

' Set up some regular expression objects
Set RE0 = New RegExp
Set RE2 = New RegExp

RE0.Pattern = &quot;OK&quot;
RE2.Pattern = &quot;Degraded&quot;

' Check for no output
If oExec.StdOut.AtEndOfStream Then
Failed = 3
Else
While Not oExec.StdOut.AtEndOfStream
Line = oExec.StdOut.ReadLine

' Tests for Healthy volumes
If RE0.Test(Line) Then
If Failed = -1 Then Failed = 0
End If

' Tests for Failed RAID volumes
If RE2.Test(Line) Then
If Failed < 2 Then Failed = 2
End If
WEnd
End If

' If Failed is still -1, something bad has happened, or there is no RAID
If Failed = -1 Then Failed = 3

' Print out the appropriate test result
Select Case Failed
Case 0
WScript.StdOut.WriteLine(&quot;RAID OK: All volumes Healthy&quot;)
Case 2
WScript.StdOut.WriteLine(&quot;RAID CRITICAL: Volume(s) degraded&quot;)
Case 3
WScript.StdOut.WriteLine(&quot;UNKNOWN: &quot; + oExec.StdErr.ReadLine)
End Select

WScript.Quit(Failed)