我知道我来晚了,但最近一直在做一个项目,并提出了这个可能会有所帮助的建议:
$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)。
让我知道事情的后续。