0

Is there any windows api which returns if the drive is of nvme type? In powershell, when I do

Get-PhysicalDisk | select Friendlyname, BusType, MediaType 

it gives the MediaType as SSD and the BusType as RAID. Ealier, I was using the STORAGE_BUS_TYPE win32 for checking NVMe by using the BusType, but I have an SSD Nvme device which has BusType as RAID.

Thanks.

user3615045
  • 193
  • 2
  • 13

1 Answers1

0

I know I'm a little late but have recently been working on a project and have come up with this which may help:

$bustype_table = @{ #bus type table taken from Microsofts webiste
    '0' = 'The bus type is unknown.'
    '1' = 'SCSI'
    '2' = 'ATAPI'
    '3' = 'ATA'
    '4' = 'IEEE 1394'
    '5' = 'SSA'
    '6' = 'Fibre Channel'
    '7' = 'USB'
    '8' = 'RAID'
    '9' = 'iSCSI'
    '10' = 'Serial Attached SCSI (SAS)'
    '11' = 'Serial ATA (SATA)'
    '12' = 'Secure Digital (SD)'
    '13' = 'Multimedia Card (MMC)'
    '14' = 'This value is reserved for system use (Virtual)'
    '15' = 'File-Backed Virtual'
    '16' = 'Storage spaces'
    '17' = 'NVMe'
}


try
{
    $windows_version = (Get-WmiObject Win32_OperatingSystem).Version #Gets windows version.
    if($windows_version -gt 10.0.00000) #has to be windows 10.0 or higher. wont work on 7 or 8.
   {
        $bustype = wmic /namespace:\\root\microsoft\windows\storage path msft_disk get BusType #,Model
        $bustype_value = $bustype[2].Trim() #trims whitespace from the bustype value.
        $drive_connection = $bustype_table[$bustype_value] #calls the table.
     Write-Host "The C drive is connected via: $drive_connection `r`n"
    }
}
catch
{
    $_.Exception.Message #windows version is pre windows 10. Script wont work.
}

Specifically, this is what you want I think:

wmic /namespace:\\root\microsoft\windows\storage path msft_disk get Model,BusType

Although, this may not work as you have stated that your NVMe drives are in raid so it may pick it up as '8' (RAID).

Let me know how it goes.

Gingco
  • 3
  • 1
  • Forgot to add the Microsoft documentation link: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-disk?redirectedfrom=MSDN – Gingco Apr 09 '21 at 15:54