-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdisk-model.ps1
More file actions
28 lines (27 loc) · 1 KB
/
disk-model.ps1
File metadata and controls
28 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This powershell script is used to map drive letters to disk model numbers
# It is intended to be called by Runtime.getRuntime().exec(...)
Get-WmiObject Win32_DiskDrive | % {
$disk = $_
$partitions = "ASSOCIATORS OF " +
"{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
"WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Get-WmiObject -Query $partitions | % {
$partition = $_
$drives = "ASSOCIATORS OF " +
"{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
"WHERE AssocClass = Win32_LogicalDiskToPartition"
Get-WmiObject -Query $drives | % {
New-Object -Type PSCustomObject -Property @{
#Disk = $disk.DeviceID
#DiskSize = $disk.Size
DiskModel = $disk.Model
#Partition = $partition.Name
#RawSize = $partition.Size
DriveLetter = $_.DeviceID
#VolumeName = $_.VolumeName
#Size = $_.Size
#FreeSpace = $_.FreeSpace
}
}
}
}