Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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

share|improve this answer
    
Thanks a tonn . This really solved my problem. – Vaibhav Sep 11 '12 at 12:05

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

Get-WmiObject -Class win32_diskdrive -Property STATUS
share|improve this answer
    
+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.

share|improve this answer

Get-WmiObject -Class win32_diskdrive | fl deviceid,serialnumber

share|improve this answer
1  
This answer needs explanation. – kasperd Apr 28 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 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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