VMware Cloud Community
Mike_Yazbeck
Enthusiast
Enthusiast

Get Disk Status i.e. Online / Offline in 2008/2012 via WMI & PowerCLI

Hey Guys :smileygrin:

Just wondering, does anyone know how to identify offline disks within Windows via WMI and PowerCLI?

I need both ideally as I want to improve my SCSI ID match to hard disk script.

Right now it does everything I want except provide the status of the disk... the problem is, even when a disk is "offline" it still reads as "Status OK" in WMI. There has to be somekind of key or parameter in WMI that will allow me to determine if the disk is offline or online - this is the last thing I really need for my script for it to be 100% complete.

Thanks all :smileygrin:

4 Replies
binoche
VMware Employee
VMware Employee

not sure if I understand your question correctly, in windows 2012, powershell its cmdlet get-disk should report disk offline or online?

Reply
0 Kudos
Mike_Yazbeck
Enthusiast
Enthusiast

My code has to run remotely, it defeats the purpose if I have to run it locally.

I did check that command your provided and it works perfectly, but unfortunately its unavailable for Windows 7 and Server 2008. It doesnt appear to be remotely executable in that I cannot probe a machine remotely to pull information so this cmdlet isnt great, but at least we have one.

Is there no way to query this using WMI or PowerCLI without explicitly using a commandlet designed for Server 2012?

Reply
0 Kudos
LucD
Leadership
Leadership

Don't know of any WMI class that will show this info.

But you can do this (remotely)

Invoke-Command -ComputerName MySrv -ScriptBlock {"list disk" | diskpart}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Mike_Yazbeck
Enthusiast
Enthusiast

Admittedly I have seen this code on the Microsoft forums:

Invoke-Command -ComputerName srv1 -ScriptBlock {"list disk" | diskpart | Where {$_ -match "Offline"}}

https://social.technet.microsoft.com/Forums/windowsserver/en-US/b7eedcd4-e712-4910-bc4a-2492992425b0...

I was hoping to get around the need to use Invoke-Command Smiley Sad

Thanks for the advice guys, i'll keep looking.

Reply
0 Kudos