Private/Get-Cards.ps1

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
29
30
31
32
33
34
35
36
function Get-Cards {
    function global:Get-OSVersion {
        return ([Environment]::OSVersion)
    }

    $OSVersion = Get-OSVersion

    Write-Verbose ('OS Version information: {0}' -f $OSVersion | Format-Table)

    Switch ($OSVersion.Version.Major) {
        6 {
            $CardPath = 'HKLM:\SYSTEM\CurrentControlSet\Hardware Profiles\UnitedVideo\CONTROL\VIDEO\'
        }

        10 {
            if ($OSVersion.Version.Build -ge '17763') {
                $CardPath ='HKLM:\SYSTEM\CurrentControlSet\Control\UnitedVideo\CONTROL\VIDEO\'
            } else {
                $CardPath = 'HKLM:\SYSTEM\CurrentControlSet\Hardware Profiles\UnitedVideo\CONTROL\VIDEO\'
            }
        }

        # default {
        # Throw('Error getting registry card path')
        # }
    }


    try {
        $Cards = Get-ChildItem $CardPath -ErrorAction Stop
    } catch {
        Throw('Error getting graphics cards')
    }
 
    return $Cards
}