View difference between Paste ID: 8LrnjSAM and fXGkZTZS
SHOW: | | - or go back to the newest paste.
1
$SystemInfo = [ordered]@{}
2
3
$MfgLookup = @{
4
    Crucial = 'Crucial Technology'
5
    WDC = 'Western Digital Corporation'
6
    }
7
8
$CIM_DiskDrive = @(Get-CimInstance -ClassName CIM_DiskDrive).
9
    Where({$_.Caption -notmatch 'Generic'}) |
10
    Sort-Object -Property Index
11
12
foreach ($CDD_Item in $CIM_DiskDrive)
13
    {
14
    $Index = '{0:D2}' -f $CDD_Item.Index
15
    $ModelPrefix = ($CDD_Item.Model.Split('_ '))[0]
16
    if (($CDD_Item.Manufacturer -eq '(Standard disk drives)') -and
17
        ($ModelPrefix -in $MfgLookup.Keys))
18
        {
19
        $Mfg = $MfgLookup[$ModelPrefix]
20
        }
21
        else
22
        {
23
        $Mfg = $Null
24
        }
25
26
    $SystemInfo.Add("Disk_${Index}_Manufacturer", $Mfg)
27
    $SystemInfo.Add("Disk_${Index}_Model", $CDD_Item.Model)
28
    $SystemInfo.Add("Disk_${Index}_SN", $CDD_Item.SerialNumber.Trim())
29
    $SystemInfo.Add("Disk_${Index}_FirmwareRevision", $CDD_Item.FirmwareRevision)
30
    # the raw number is in bytes
31
    $SystemInfo.Add("Disk_${Index}_Size_GB", $('{0:N3}' -f ($CDD_Item.Size / 1GB)))
32
    $SystemInfo.Add("Disk_${Index}_PartitionCount", $CDD_Item.Partitions)
33
    $SystemInfo.Add("Disk_${Index}_Status", $CDD_Item.Status)
34
    }
35
36
$SystemInfo