5

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?

Vaibhav
  • 51
  • 1
  • 1
  • 5

4 Answers4

6

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

Get-WmiObject -Class win32_diskdrive -Property STATUS
Mike
  • 828
  • 1
  • 7
  • 18
4

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

Chris McKeown
  • 7,128
  • 1
  • 17
  • 25
1

Use WMIC: WMIC DISKDRIVE GET Availability,Index,Caption

The values for availability can be found in the MSDN.

Chris J
  • 1,218
  • 18
  • 32
0

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?](http://serverfault.com/help/how-to-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](http://serverfault.com/editing-help) 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