Powershell monitoring drive mirrors

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
lusbyr
Posts: 2
Last visit: Mon Oct 20, 2008 7:49 am

Powershell monitoring drive mirrors

Post by lusbyr »

Hello,Is there a way to use a Powershell script in Windows Server 2003 to periodically monitor (user configurable time period) the event log (or other status method) for whether or not a drive mirror has failed?Thanks
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Powershell monitoring drive mirrors

Post by jhicks »

You might be able to use the Win32_DiskDrive class and periodically check the status:get-wmiobject win32_diskdrive -computer "SERVER01" -filter "Status <> 'OK'" | Select Caption,Model,NameOr in a script you might use code like this:$check=gwmi win32_diskdrive -computer "SERVER01" -filter "Status <> 'OK'"if ($check) {"do something"}This approach is much better if you have to monitor several servers. You could set it up as a scheduled task and run it every 5 minutes.
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Powershell monitoring drive mirrors

Post by jhicks »

Then I would write a Powershell script to use my WMI query example against one or more computers and schedule it to run from your desktop or someplace every 10 minutes. You might first test it by changing the filter to Status='OK' to verify this class will do what you need. I don't have a software RAID anywhere handy where I can test. I also hope you have an environment where you can test for failed disks.
User avatar
lusbyr
Posts: 2
Last visit: Mon Oct 20, 2008 7:49 am

Powershell monitoring drive mirrors

Post by lusbyr »

Jeff, thanks - I will give this a try and let you know what happens.
This topic is 15 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked