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


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?


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


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

Get-WmiObject -Class win32_diskdrive -Property STATUS
  • +1 for single liner – dunxd Sep 11 '12 at 14:49

Use WMIC: WMIC DISKDRIVE GET Availability,Index,Caption

The values for availability can be found in the MSDN.


Get-WmiObject -Class win32_diskdrive | fl deviceid,serialnumber

  • 1
    This answer needs explanation. – kasperd Apr 28 '16 at 12:09
  • 1
    Welcome to Server Fault! It looks like you may have the knowledge to provide good Answer here, but please consider reading How do I write a good Answer? in our help center and then revise the Answer. Your Commands/Code/Settings may technically be the solution but some explanation is welcome. Also please use Markdown and/or the formatting options in the edit menu to properly type-set your posts to improve their readability, convention is to mark command/scripts/code as code. Thanks in advance. – HBruijn Apr 28 '16 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.