If you need to determine the serial number of a hard disk drive (HDD)
attached to a Microsoft Windows system, you can do so from a
PowerShell
window using the cmdlet Get-Disk (you can open a
PowerShell window by typing PowerShell
in the Windows "Type here to
search field on a Windows 10 system and then selecting the app when it is
returned in the list of search results). If you just want a list of drives
attached to the system by a USB
connection, you can pipe
the output of the cmdlet to the
Where-Object cmdlet where you can filter on just drives that have a USB
connection as shown below.
PS C:\> Get-Disk | Where-Object -FilterScript {$_.Bustype -Eq "USB"} Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style ------ ------------- ------------- ------------ ----------------- ---------- ---------- 1 SanDisk Cr... 03025228050421082418 Healthy No Media 0 B RAW 2 USB2.0 Car... 606569746800 Healthy No Media 0 B RAW 4 USB2.0 Car... 606569746802 Healthy No Media 0 B RAW 5 USB2.0 Car... 606569746803 Healthy No Media 0 B RAW 3 USB2.0 Car... 606569746801 Healthy No Media 0 B RAW 6 WD My Pass... WXM1A375CKEZ Healthy Online 931.48 GB GPT PS C:\>
If you just wish to see drives that are online when the cmdlet is run, you can add an additional condition specifying that the Operational Status is equal (eq) to "Online".
PS C:\> Get-Disk | Where-Object -FilterScript {$_.Bustype -Eq "USB" -and $_.OperationalStatus -eq "Online"} Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style ------ ------------- ------------- ------------ ----------------- ---------- ---------- 6 WD My Pass... WXM1A375CKEZ Healthy Online 931.48 GB GPT PS C:\>
Or if I am interested in a particular drive, say a Western Digital My Passport USB drive, I can filter on the "Friendly Name" for the drive knowing that "Passport" will be part of that name. Though the column header has a space between "Friendly" and "Name", the space isn't present in the object name so I omit it as shown below. If the only value I'm interested in for the drive is the serial number I can limit the output displayed by using the Select-Object cmdlet.
PS C:\> Get-Disk | Where-Object -FilterScript {$_.FriendlyName.contains("Passport")} Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style ------ ------------- ------------- ------------ ----------------- ---------- ---------- 6 WD My Pass... WX32DC2MDTDY Healthy Online 4.55 TB GPT PS C:\> Get-Disk | Where-Object -FilterScript {$_.FriendlyName.contains("Passport")} | Select-Object -Property SerialNumber SerialNumber ------------ WX32DC2MDTDY PS C:\>
If I want the serial numbers for any Western Digital drives attached to
the system, I can use the -like
option to the Where-Object
cmdlet and specify "W*"
to indicate I want to filter
the output of the Get-Disk
cmdlet to just objects, drives in
this case, that have a serial number that begins with a capital "W" followed
by any number of other characters (the asterisk is considered to be a
wildcard character).
PS C:\> Get-Disk | Where-Object -FilterScript {$_.SerialNumber -like "W*"} | Select-Object -Property SerialNumber SerialNumber ------------ WX32DC2MDTDY PS C:\>
In addition to the Get-Disk
cmdlet, you can also use the
Get-PhysicalDisk
cmdlet to obtain information about hard drives
on a Windows system.
PS C:\> Get-PhysicalDisk
Number FriendlyName SerialNumber MediaType CanPool OperationalStatus HealthStatus Usage Size
------ ------------ ------------ --------- ------- ----------------- ------------ ----- ----
0 ST2000DL001-9VT156 5YD18XT3 HDD False OK Healthy Auto-Select 1.82 TB
6 WD My Passport 2627 WX32DC2MDTDY HDD False OK Healthy Auto-Select 4.55 TB
PS C:\>
Related:
References: