Skip to main content

Reporting on Attached Monitor info as available in WMIMonitorID

I thought this information was already blogged by someone else--I certainly know I stole it from someone else years ago. But now I can't find that blog. If this is your work; please accept my apologies for not crediting you correctly.

Reporting on "Attached Monitors" is occasionally something which your business requests. The best solution in my humble opinion is from Enhansoft.com, part of their Reporting suite includes a client-deployed utility for exhaustively being able to report on attached monitor information https://www.enhansoft.com/products-services/enhansoft-reporting/ 

However, if you don't have any budget at all; but are still tasked with getting "attached monitor information", although it's a poor second, you can get 'some information' out of a built-in WMI class. https://docs.microsoft.com/en-us/windows/win32/wmicoreprov/wmimonitorid 

Step 1: In your CM Console, Administration, Client Settings, right-click on Default Client Settings, select Properties. Go to the "hardware inventory" on the left, then "Set Classes..." on the right. Choose "Add..." and you want to connect to <some computer you have admin rights on> root\wmi (not root\cimv2), and find "WMIMonitoID". Add that. hit OK til out. Monitor <your server>\logs\dataldr.log; to see it being created, and the view created. Take note of the view which was created in your environment.

Step 2: Wait. You are waiting for clients to get this new policy, and then report hardware inventory using this new policy. Depending upon your environment, this could be minutes to hours to even a week--only you know your own environment and timings.

Step 3: Below is sql code to pull out the information from the 'not too friendly' info in that wmi class. Just make sure you replace the v_gs_wmimonitorID0 view with what it REALLY is for your environment. Your environment might not have called the view v_gs_wmimonitorID0; again; that could be unique to your environment.

If(OBJECT_ID('tempdb..#TempMonInfo') Is Not Null)
Begin
Drop Table #TempMonInfo
End

--###############################################
--Create #Temp Table, and insert specific data
--Data will be used later in the report
--##############################################

create table #TempMonInfo(
ResourceID int,
UserFriendlyName0 nvarchar(255),
UserFriendlyNameLength0 int,
UserFriendlyNameConv varchar(255),
ManufacturerName0 nvarchar(255),
ProductCodeID0 nvarchar(255),
SerialNumberID0 nvarchar(255),
WeekOfManufacture0 int,
YearOfManufacture0 int
)

insert Into #TempMonInfo
(ResourceID, ManufacturerName0, ProductCodeID0, SerialNumberID0, WeekOfManufacture0, YearOfManufacture0,
UserFriendlyName0, UserFriendlyNameLength0)
select
ResourceID, ManufacturerName0, ProductCodeID0, SerialNumberID0, WeekOfManufacture0, YearOfManufacture0,
UserFriendlyName0, UserFriendlyNameLength0
from v_GS_WMIMonitorID0

;WITH n AS
(
SELECT
NUMBER = ROW_NUMBER() OVER (ORDER BY s1.[object_id])
FROM sys.all_objects AS s1, sys.all_objects AS s2
)
, final as (
SELECT
MON.ResourceID,
MON.UserFriendlyName0,
CONV_FN.VAL AS UserFriendlyNameConverted,
MON.ManufacturerName0 AS [Make],
CONV_MAKE.VAL AS MakeConverted,
MON.ProductCodeID0 AS [ProductCode],
MON.SerialNumberID0 AS [SerNum],
CONV_SN.VAL AS SerNumConverted,
MON.YearOfManufacture0 AS [YearOfManufacture],
MON.WeekOfManufacture0 AS [WeekOfManufacture]
FROM #TempMonInfo MON
CROSS APPLY ( SELECT
CASE
WHEN UserFriendlyName0 LIKE '%,%'
THEN (SELECT CHAR([value]) FROM (SELECT [Value] = SUBSTRING(MON.UserFriendlyName0, [Number],CHARINDEX(',', MON.UserFriendlyName0 + ',', [Number]) - [Number]) FROM n WHERE Number <= LEN(MON.UserFriendlyName0) AND SUBSTRING(',' + MON.UserFriendlyName0, [Number], 1) = ',') SPLT WHERE [value] > 20 FOR XML PATH(''),TYPE).value('.','varchar(max)')
ELSE UserFriendlyName0
END AS VAL) CONV_FN
CROSS APPLY ( SELECT
CASE
WHEN MON.ManufacturerName0 LIKE '%,%'
THEN (SELECT CHAR([value]) FROM (SELECT [Value] = SUBSTRING(MON.ManufacturerName0, [Number] ,CHARINDEX(',', MON.ManufacturerName0 + ',', [Number]) - [Number]) FROM n WHERE Number <= LEN(MON.ManufacturerName0) AND SUBSTRING(',' + MON.ManufacturerName0, [Number], 1) = ',') SPLT WHERE [value] > 20 FOR XML PATH(''),TYPE).value('.','varchar(max)')
ELSE MON.ManufacturerName0
END AS VAL) CONV_MAKE
CROSS APPLY ( SELECT
CASE
WHEN MON.SerialNumberID0 LIKE '%,%'
THEN (SELECT CHAR([value]) FROM (SELECT [Value] = SUBSTRING(MON.SerialNumberID0, [Number],CHARINDEX(',', MON.SerialNumberID0 + ',', [Number]) - [Number]) FROM n WHERE Number <= LEN(MON.SerialNumberID0) AND SUBSTRING(',' + MON.SerialNumberID0, [Number], 1) = ',') SPLT WHERE [value] > 20 FOR XML PATH(''),TYPE).value('.','varchar(max)')
ELSE MON.SerialNumberID0
END AS VAL) CONV_SN
)

Select
s1.Netbios_Name0 as 'Computername',
final.resourceid,
final.makeconverted
, UserFriendlyNameConverted
, final.ProductCode,
final.SerNumConverted, final.WeekOfManufacture, final.YearOfManufacture
,case when makeconverted = 'aaa' then 'Asus'
when makeconverted= 'ACI' then 'Asus'
when makeconverted= 'ACR' then 'Acer'
when makeconverted= 'APP' then 'Apple'
when makeconverted= 'ATL' then 'Atlona'
when makeconverted= 'BBY' then 'Insignia'
when makeconverted= 'BNQ' then 'Benq'
when makeconverted= 'CPQ' then 'Compaq'
when makeconverted= 'DCL' then 'DCLCD'
when makeconverted= 'DEL' then 'Dell'
when makeconverted= 'ELE' then 'Element'
when makeconverted= 'ELM' then 'Doublesight'
when makeconverted= 'EMA' then 'eMachines'
when makeconverted= 'ENC' then 'Eizo'
when makeconverted= 'EPI' then 'Envision'
WHEN makeconverted= 'FNI' then 'FUNAI/SYLVANIA'
when makeconverted= 'GSM' then 'LG'
when makeconverted= 'GWY' then 'Gateway'
when makeconverted= 'HKC' then 'V7'
when makeconverted= 'HPN' then 'HP'
when makeconverted= 'HRE' then 'Haier'
when makeconverted= 'ACR' then 'Acer'
when makeconverted= 'HSD' then 'Hanns.G'
when makeconverted= 'ACR' then 'Acer'
when makeconverted= 'HSP' then 'Hannspree'
when makeconverted= 'HTC' then 'Hitachi'
when makeconverted= 'HWP' then 'HP'
when makeconverted= 'IFS' then 'Infocus'
when makeconverted= 'IZI' then 'Vizio'
when makeconverted= 'LEN' then 'Lenovo'
when makeconverted= 'MED' then 'Medion'
when makeconverted= 'MEL' then 'NEC/Mitsubishi'
when makeconverted= 'NOK' then 'Nokia'
when makeconverted= 'PGS' then 'Princeton'
when makeconverted= 'PHL' then 'Philips'
when makeconverted= 'PLN' then 'Planar'
when makeconverted= 'PNR' then 'Planar'
when makeconverted= 'PTS' then 'Proview'
when makeconverted= 'SAM' then 'Samsung'
when makeconverted= 'SEK' then 'Seiki'
when makeconverted= 'SHP' then 'Sharp'
when makeconverted= 'SNY' then 'Sony'
when makeconverted= 'SPT' then 'Sceptre'
when makeconverted= 'SYN' then 'Olevia'
when makeconverted= 'TSB' then 'Toshiba'
when makeconverted= 'UPS' then 'Upstar'
when makeconverted= 'VIZ' then 'Vizio'
when makeconverted= 'VSC' then 'ViewSonic'
when makeconverted= 'WDE' then 'Westinghouse'
when makeconverted= 'WDT' then 'Westinghouse'
when makeconverted= 'WET' then 'Westinghouse'
else MakeConverted
end as 'BestGuessMake'
from Final
join v_R_System_Valid s1 on s1.resourceid=final.resourceid
-- Filtering out some Makes known to not be relevant ... at least when this report was created years ago.
-- Comment out the next line if you want these things anyway.
and Final.Make not in ('AUO','BOE','SEC','SDC','LGD','CMN','64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0','77, 83, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0','88, 72, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0')

If(OBJECT_ID('tempdb..#TempMonInfo') Is Not Null)
Begin
Drop Table #TempMonInfo
END

CMCB, SQL

  • Created on .