Scripts/Get-PCVideoController.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Function Get-PCVideoController {

    <#
 
    .SYNOPSIS
    Get video card information/configuration
 
    .DESCRIPTION
    Get video card information/configuration
 
    .PARAMETER ComputerName
    Name of the target computer
 
    .EXAMPLE
    Get-PCVideoController -ComputerName LabPC2024
 
    .NOTES
    N/A
 
    .LINK
    N/A
 
    #>


    [CmdletBinding ()]

    Param (

        [Parameter (Mandatory = $True,
                    ValueFromPipeline = $True,
                    ValueFromPipelineByPropertyName = $True,
                    HelpMessage = 'Enter computer name'
                   )
        ]

        [String[]]$ComputerName

    )

    BEGIN {

        $VideoAvailability = @{

            '1' = 'Other'
            '2' = 'Unknown'
            '3' = 'Running/Full power'
            '4' = 'Warning'
            '5' = 'In test'
            '6' = 'Not applicable'
            '7' = 'Power off'
            '8' = 'Off line'
            '9' = 'Off duty'
            '10' = 'Degraded'
            '11' = 'Not installed'
            '12' = 'Install error'
            '13' = 'Power save/Unknown'
            '14' = 'Power save/Low power mode'
            '15' = 'Power save/Standby'
            '16' = 'Power cycle'
            '17' = 'Power save/Warning'
            '18' = 'Paused'
            '19' = 'Not ready'
            '20' = 'Not configured'
            '21' = 'Quiet'

        }

        $VideoArchitecture = @{

            '1' = 'Other'
            '2' = 'Unknown'
            '3' = 'CGA'
            '4' = 'EGA'
            '5' = 'VGA'
            '6' = 'SVGA'
            '7' = 'MDA'
            '8' = 'HGC'
            '9' = 'MCGA'
            '10' = '8514A'
            '11' = 'XGA'
            '12' = 'Linear frame buffer'
            '160' = 'PC-98'

        }

        $VideoScanMode = @{

            '1' = 'Other'
            '2' = 'Unknown'
            '3' = 'Interlaced'
            '4' = 'Non interlaced'

        }

        $VideoMemoryType = @{

            '1' = 'Other'
            '2' = 'Unknown'
            '3' = 'VRAM'
            '4' = 'DRAM'
            '5' = 'SRAM'
            '6' = 'WRAM'
            '7' = 'EDO RAM'
            '8' = 'Burst synchronous DRAM'
            '9' = 'Pipelined burst SRAM'
            '10' = 'CDRAM'
            '11' = '3DRAM'
            '12' = 'SDRAM'
            '13' = 'SGRAM'

        }

        Function Show-Output ($Computer, $Values, $Status) {

            [PSCustomObject]@{

                ComputerName = $Computer
                Caption = $Values.Caption
                DeviceID = $Values.DeviceID
                AdapterCompatibility = $Values.AdapterCompatibility
                AdapterDACType = $Values.AdapterDACType
                AdapterRAM = "$(($Values.AdapterRAM) / 1GB)$(' GB')"
                Availability = $VideoAvailability["$($Values.Availability)"]
                VideoArchitecture = $VideoArchitecture["$($Values.VideoArchitecture)"]
                CurrentBitsPerPixel = $Values.CurrentBitsPerPixel
                CurrentHorizontalResolution = $Values.CurrentHorizontalResolution
                CurrentVerticalResolution = $Values.CurrentVerticalResolution
                CurrentNumberOfColors = $Values.CurrentNumberOfColors
                CurrentNumberOfColumns = $Values.CurrentNumberOfColumns
                CurrentNumberOfRows = $Values.CurrentNumberOfRows
                CurrentRefreshRate = $Values.CurrentRefreshRate
                CurrentScanMode = $VideoScanMode["$($Values.CurrentScanMode)"]
                MaxMemorySupported = $Values.MaxMemorySupported
                MaxNumberControlled = $ValuesMaxNumberControlled
                MaxRefreshRate = $Values.MaxRefreshRate
                MinRefreshRate = $Values.MinRefreshRate
                Monochrome = $Values.Monochrome
                VideoMemoryType = $VideoMemoryType["$($Values.VideoMemoryType)"]
                VideoProcessor = $Values.VideoProcessor
                DriverVersion = $Values.DriverVersion
                Status = $Status

            }

        }

    }

    PROCESS {

        ForEach ($Computer In $ComputerName) {

            If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) {

                Try {

                    $Data = Get-WmiObject Win32_VideoController -ComputerName $Computer | Select-Object *

                    ForEach ($Item In $Data) {

                        Show-Output $Computer.ToUpper() $Item 'Ok'

                    }

                }

                Catch {

                    Show-Output $Computer.ToUpper() $Null $PSItem.Exception.Message

                }

            }

            Else {

                Show-Output $Computer.ToUpper() $Null 'Unreachable'

            }

        }

    }

    END {}

}