command line for getting information about status of disk?

Here is the scenario, I have Windows Server 2003 and 2008 which is connected LUNs. I wanted to get status of the disk if disks are online or offline using command line.

I'm trying to execute diskpart /s sample.txt and sample.txt contains

SELECT DISK=1
CREATE PARTITION primary 

So, the above command is not getting executed , because the disk is offline. Is there any native "command line utility" or script to check the status of LUNs assigned to system?


Solution 1:

Launch DISKPART and run LIST DISK. The status column will show if they're online or not.

Solution 2:

You can use the following code to get the status of a drive. This is powershell code.

Get-WmiObject -Class win32_diskdrive -Property STATUS

Solution 3:

Use WMIC: WMIC DISKDRIVE GET Availability,Index,Caption

The values for availability can be found in the MSDN.