0

如果驱动器是 nvme 类型,是否有任何返回的 windows api?在powershell中,当我这样做时

Get-PhysicalDisk | select Friendlyname, BusType, MediaType 

它给出了 MediaType asSSD和 BusType as RAID。之前,我使用STORAGE_BUS_TYPEwin32 通过 BusType 检查 NVMe,但我有一个 SSD Nvme 设备,它的 BusType 为 RAID。

谢谢。

4

1 回答 1

0

我知道我来晚了,但最近一直在做一个项目,并提出了这个可能会有所帮助的建议:

$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.
}

具体来说,这就是你想要的我认为:

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

虽然,这可能不起作用,因为您已声明您的 NVMe 驱动器处于 RAID 状态,因此它可能会将其选为“8”(RAID)。

让我知道事情的后续。

于 2021-04-09T15:52:05.357 回答