Windows – How to check integrity of the builtin windows 2003 software raid from a script

pythonraidsoftware-raidwindowswindows-server-2003

I want to write a script (using python or windows batch) to check if in the raid system on a winows 2003 server all disks are online, alive and synced.

This is the builtin windows 2003 software raid that I am using.

How can I get this information from a script that I run periodically?

Edit: I tried the code form the accepted answer. On my system all the disk information is given, except "Status", which always returns "None".

I found another soulution here:

http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid

Calling "echo list volume | diskpart" from a script and checking the returned output with regular expressions. There is one line for each drive. Possible string values for status depend on the language of your OS. Not very nice but works.

Best Answer

You're looking for the Win32_LogicalDisk WMI class (Specifically the status property)

You could use either PowerShell or VBScript to access this class.

Note I Don't have a Software Raid setup to test these against and they are just samples not fully fleshed out code

A quick PowerShell Script would look something like this:

$CheckDrive = gwmi -query "Select * from Win32_LogicalDisk where DeviceID='C:'"
$CheckDrive.properties.status

Or if you wanted to loop through a bunch of drives you could do something like:

$CheckDrive = gwmi Win32_LogicalDisk
foreach ($i in $CheckDrive){$i.properties.Status}

From the linked site here are the options of the status output:

Status

   Data type: string
   Access type: Read-only

Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states. This property is inherited from CIM_ManagedSystemElement.

   The values are:

   "OK"
   "Error"
   "Degraded"
   "Unknown"
   "Pred Fail"
   "Starting"
   "Stopping"
   "Service"
   "Stressed"
   "NonRecover"
   "No Contact"
   "Lost Comm"
Related Topic