After a lot of research, try and error, I got a code that could get as close as possible to the monitors serial number but not the actual serial number.
$Monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
$LogFile = "C:\test\monitors.txt"
function Decode {
If ($args[0] -is [System.Array]) {
[System.Text.Encoding]::ASCII.GetString($args[0])
}
Else {
"Not Found"
}
}
echo "Manufacturer", "Name, Serial"
ForEach ($Monitor in $Monitors) {
$Manufacturer = Decode $Monitor.ManufacturerName -notmatch 0
$Name = Decode $Monitor.UserFriendlyName -notmatch 0
$Serial = Decode $Monitor.SerialNumberID -notmatch 0
echo "$Manufacturer, $Name, $Serial" >> $LogFile
}
The name of manufactural is Acer but the code's output is ACR. Regarding the serial number, which I'm more interested, only a few digits matches. Is there another keywords or line of code that I can use to extract the exact (pretty long) serial number?