-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-ClientMonitorEDIDData.ps1
More file actions
93 lines (84 loc) · 4.09 KB
/
Copy pathGet-ClientMonitorEDIDData.ps1
File metadata and controls
93 lines (84 loc) · 4.09 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
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
<#
.SYNOPSIS
Liest Hersteller, Modell, Seriennummer und Anschlussart der an einem
Rechner angeschlossenen Monitore aus.
.DESCRIPTION
Wertet die WMI-Klassen WmiMonitorID und WmiMonitorConnectionParams im
Namespace root\wmi aus. Die Angaben stammen aus dem EDID-Block des
Monitors, sind also die Herstellerdaten und nicht das, was Windows in der
Geraeteverwaltung anzeigt.
Nuetzlich fuer Inventarisierung und Garantiefaelle - die Seriennummer
steht sonst nur auf einem Aufkleber an der Rueckseite.
.NOTES
Braucht WMI-Zugriff auf den Zielrechner. Manche Monitore, besonders
aeltere und ueber Adapter angeschlossene, liefern unvollstaendige oder
leere EDID-Daten.
#>
function Get-ClientMonitorEDIDData {
param (
[string]$Computer = "localhost"
)
Try {
$monitors = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorID -ComputerName $Computer -ErrorAction Stop
$connections = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorConnectionParams -ComputerName $Computer -ErrorAction Stop
$result = foreach ($monitor in $monitors) {
$connection = $connections | Where-Object { $_.InstanceName -eq $monitor.InstanceName }
[PSCustomObject]@{
Active = $monitor.Active
InstanceName = $monitor.InstanceName
Manufacturer = ([System.Text.Encoding]::ASCII.GetString($monitor.ManufacturerName) -replace '\x00')
ProductCode = ([System.Text.Encoding]::ASCII.GetString($monitor.ProductCodeID) -replace '\x00')
SerialNumber = ([System.Text.Encoding]::ASCII.GetString($monitor.SerialNumberID) -replace '\x00')
UserFriendlyName = ([System.Text.Encoding]::ASCII.GetString($monitor.UserFriendlyName) -replace '\x00')
UserFriendlyNameLength = $monitor.UserFriendlyNameLength
WeekOfManufacture = $monitor.WeekOfManufacture
YearOfManufacture = $monitor.YearOfManufacture
ConnectionType = Switch ($connection.VideoOutputTechnology) {
-2 { "Uninitialized" }
-1 { "Other" }
0 { "HD15 (VGA)" }
1 { "S-Video" }
2 { "Composite Video (RF)" }
3 { "Component Video (RCA/BNC)" }
4 { "DVI" }
5 { "HDMI" }
6 { "LVDS" }
8 { "D-JPN" }
9 { "SDI" }
10 { "DisplayPort External" }
11 { "DisplayPort Embedded" }
12 { "UDI External" }
13 { "UDI Embedded" }
14 { "SDTV Dongle" }
15 { "Miracast" }
16 { "Indirect Wired" }
0x80000000 { "Internal" }
default { "Unknown" }
}
PSComputerName = $monitor.PSComputerName
}
}
return $result
} catch {
$result = [PSCustomObject]@{
Active = ""
InstanceName = ""
Manufacturer = ""
ProductCode = ""
SerialNumber = ""
UserFriendlyName = ""
UserFriendlyNameLength = ""
WeekOfManufacture = ""
YearOfManufacture = ""
ConnectionType = ""
PSComputerName = ""
}
return $result
}
}
# Get-ClientMonitorEDIDData -Computer "MYHOSTNAME"
# Example to use the Scriptblock of the function for remote execution on one computer. On the Computer the script runs and the parameter Computer is then "localhost"
# Invoke-Command -ScriptBlock (Get-Command Get-ClientMonitorEDIDData).ScriptBlock -ComputerName MYHOST
# Use this knowledge to execute the function on many computers and then collect this for further analysis... (see Get-TasksAndServices.ps1)
# $allemonitore = @()
# $allemonitore += Invoke-Command -ComputerName ($computers | Where-Object {$_}) -ThrottleLimit $throttleLimit -ScriptBlock (Get-Command Get-ClientMonitorEDIDData).ScriptBlock -Credential $credentials