I've been trying to retrieve information about remote computers in our network via a WMI query. This works fine for all the info I need, I just don't seem to get the UserFriendlyName from the WmiMonitorID class. As this value is stored as a uint16.
The code below returns System.UInt16[]
But I would like to get some readable information.
This is the method I use to retrieve the information:
GetDirectWmiQuery("UserFiendlyName", "WmiMonitorID");
public static string GetDirectWmiQuery(string item, string table)
{
string result = string.Empty;
ManagementScope scope;
scope = new ManagementScope($"\\\\{Var.hostnm}\\root\\WMI");
scope.Connect();
ObjectQuery query = new ObjectQuery($"Select {item} FROM {table}");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
result += m[item].ToString();
}
return result;
}