RAID Volumes and RAID Levels (if any) with PS or VB.net

~OSD~ 2,196 Reputation points
2023-01-26T23:03:06.4866667+00:00

Hi,

Is it possible to know if the disk has RAID configuration or not. If RAID is configured, the information of the RAID volumes using VB.Net or PowerShell?

This is what I have checked so far, but not desired results:

  • PowerShell:

Get-PhysicalDisk

Get-Partition

Get-Volume

  • VB.Net With "Win32_DiskDrive", I can get info like device ID, Type, etc. but not what I was looking for it.

 Dim DiskInfo As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_DiskDrive")
           
            For Each queryDisk As ManagementObject In DiskInfo.Get()

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,228 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,625 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,595 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 85,881 Reputation points
    2023-01-27T08:17:38.3133333+00:00

    It can be done with VDS and Storage Pool Object, but complicated, with P/Invoke


  2. Limitless Technology 44,401 Reputation points
    2023-02-01T11:20:52.3566667+00:00
    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.
    
    
    Yes, it is possible to determine if a disk has a RAID configuration and retrieve information about the RAID volumes using VB.Net or PowerShell.
    
    In VB.Net, you can use the WMI (Windows Management Instrumentation) classes to query the RAID configuration information. The Win32_DiskDrive and Win32_DiskDriveToDiskPartition classes can be used to retrieve information about the physical disks and partitions, respectively.
    
    
    You can use the following example VB.Net code to check if a disk has a RAID configuration:
    
    Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDriveToDiskPartition")
    
    For Each queryObj As ManagementObject In searcher.Get()
        If queryObj("Antecedent").ToString().Contains("RAID") Then
            Console.WriteLine("Disk has RAID configuration.")
        Else
            Console.WriteLine("Disk does not have RAID configuration.")
        End If
    Next
    
    
    In PowerShell, you can use the Get-Disk and Get-VirtualDisk cmdlets to retrieve information about the physical disks and virtual disks, respectively.
    
    
    
    You can use the following example PowerShell code to check if a disk has a RAID configuration:
    
    $disks = Get-Disk
    foreach ($disk in $disks) {
        if ($disk.IsSystem) {
            Write-Host "Disk $($disk.Number) is RAID:" $disk.IsRAID
        }
    }
    
    
    To retrieve information about the RAID volumes, you can use the following PowerShell cmdlet:
    
    Get-VirtualDisk
    
    
    This will show you the RAID volume name, health status, size, and other information.
    
    It's worth noting that not all RAID configurations are exposed to the operating system as RAID. Some RAID configurations are handled by the hardware controller, and in this case, the operating system doesn't see the RAID configuration.
    
    To check if the RAID is handled by the controller you can check the RAID controller management software.
    
    You can also check the RAID configuration settings in the BIOS or UEFI firmware settings.
    
    
    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.