Tuesday, July 21, 2015

Retreive Monitor Serial Number

Retrieve Monitor Serial Number Using PowerShell

Small script to retrieve monitor serial number using PowerShell,
using a WMI method called WmiMonitorID under the root\wmi namespace.

This WMI method exist from Vista and above, if you are having XP and below, you still can retrieve the information using a registry query and convert the EDID to the monitor information which include the monitor serial number.

Script Below



# Import Computers from txt file
$Computers = Get-Content C:\temp\List.txt

# Foreach loop
$BigOutput = foreach ($Computer in $Computers) {
    
    # Create output object
    $output = "" | Select-Object -Property Computer, Manufacturer, ProductCode, SerialNumber, Name, Week, Year
    
    # Get all connected monitors using WMI class WmiMonitorID
    $Monitors = Get-WmiObject -Namespace root\wmi -Class WmiMonitorID -ComputerName $Computer

        # Internal foreach loop to go over each connected monitor
        foreach ($Monitor in $Monitors) {
            
            $output.Computer = $Computer
            # get monitor info and convert to char
            $Monitor.ManufacturerName | foreach {$output.Manufacturer += [char]$_}
            $Monitor.ProductCodeID | foreach {$output.ProductCode += [char]$_}
            $Monitor.SerialNumberID | foreach {$output.SerialNumber += [char]$_}
            $Monitor.UserFriendlyName | foreach {$output.Name += [char]$_}
            # Get week and year
            $output.Week = $Monitor.WeekOfManufacture
            $output.Year = $Monitor.YearOfManufacture
            $output
            $output = "" | Select-Object -Property Computer, Manufacturer, ProductCode, SerialNumber, Name, Week, Year

        } #END internal foreach loop

} # END foreach loop

# Export result to CSV file
$BigOutput | Export-Csv C:\GetMonitorSN.csv


Enjoy!



No comments:

Post a Comment