$SystemInfo = [ordered]@{}
$MfgLookup = @{
Crucial = 'Crucial Technology'
WDC = 'Western Digital Corporation'
}
$CIM_DiskDrive = @(Get-CimInstance -ClassName CIM_DiskDrive).
Where({$_.Caption -notmatch 'Generic'}) |
Sort-Object -Property Index
foreach ($CDD_Item in $CIM_DiskDrive)
{
$Index = '{0:D2}' -f $CDD_Item.Index
$ModelPrefix = ($CDD_Item.Model.Split('_ '))[0]
if (($CDD_Item.Manufacturer -eq '(Standard disk drives)') -and
($ModelPrefix -in $MfgLookup.Keys))
{
$Mfg = $MfgLookup[$ModelPrefix]
}
else
{
$Mfg = $Null
}
$SystemInfo.Add("Disk_${Index}_Manufacturer", $Mfg)
$SystemInfo.Add("Disk_${Index}_Model", $CDD_Item.Model)
$SystemInfo.Add("Disk_${Index}_SN", $CDD_Item.SerialNumber.Trim())
$SystemInfo.Add("Disk_${Index}_FirmwareRevision", $CDD_Item.FirmwareRevision)
# the raw number is in bytes
$SystemInfo.Add("Disk_${Index}_Size_GB", $('{0:N3}' -f ($CDD_Item.Size / 1GB)))
$SystemInfo.Add("Disk_${Index}_PartitionCount", $CDD_Item.Partitions)
$SystemInfo.Add("Disk_${Index}_Status", $CDD_Item.Status)
}
$SystemInfo
Comments