PowerShell – Detect an SSD Disk Using a Script

0
54

Here is a basic script that will output a simple onscreen message showing the type, bus and SSD status of a given drive letter.

; Some constants
Const $DT_DRIVETYPE = 1
Const $DT_SSDSTATUS = 2
Const $DT_BUSTYPE = 3
 
; Drive letter to check
Const $DriveLetter = "C:"
 
; Get drive type and verify it exists
$type = DriveGetType($DriveLetter, $DT_DRIVETYPE)
If @error Then
    MsgBox(4096, "Error", "Invalid drive requested")
    Exit
EndIf
 
; Get SSD status (blank return is non-SSD)
$ssd = DriveGetType($DriveLetter, $DT_SSDSTATUS)
If $ssd = "" Then $ssd = "Non SSD"
 
; Get Bus type
$bus = DriveGetType($DriveLetter, $DT_BUSTYPE)
 
; Create output message
$output = "Type: " & $type & @CRLF
$output &= "SSD: " & $ssd & @CRLF
$output &= "Bus: " & $bus
MsgBox(4096, "Drive Info", $output)