Discussion:
Getting computer serial number through WMI
(too old to reply)
Lurka
2006-01-19 14:23:47 UTC
Permalink
Hello,

this issue comes up periodically, especially when people have to check
a thousand computers for serial numbers.

The following simple VBA script I found out there works fine (provided
I have admin rights on the target machine).

strComputer = "[COMPUTER NAME HERE]"
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from
Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
Wscript.Echo "Serial Number: " & objSMBIOS.SerialNumber
Next

I'd like to "extend" the above script to browse through a given list of
machine names and report the results in a CSV text file, including the
following properties: __SERVER, SerialNumber, Manufacturer, currently
logged user.

The logged user does not appear in the Win32_SystemEnclosure class, of
course: which class is it listed in?

Some network administrative utilities include wizards to perform WMI
queries, e.g. Hyena by SystemTools Software, but it seems that Hyena
can only query a single class at once.
Do you know of more sophisticated tools that allow to create reports
form WMI queries?

Thank you,
/_urka
Jonathan Liu [MSFT]
2006-01-19 17:38:19 UTC
Permalink
For Currently logged on user see the Win32_Computersystem class. The
property is UserName.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_computersystem.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Post by Lurka
Hello,
this issue comes up periodically, especially when people have to check
a thousand computers for serial numbers.
The following simple VBA script I found out there works fine (provided
I have admin rights on the target machine).
strComputer = "[COMPUTER NAME HERE]"
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from
Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
Wscript.Echo "Serial Number: " & objSMBIOS.SerialNumber
Next
I'd like to "extend" the above script to browse through a given list of
machine names and report the results in a CSV text file, including the
following properties: __SERVER, SerialNumber, Manufacturer, currently
logged user.
The logged user does not appear in the Win32_SystemEnclosure class, of
course: which class is it listed in?
Some network administrative utilities include wizards to perform WMI
queries, e.g. Hyena by SystemTools Software, but it seems that Hyena
can only query a single class at once.
Do you know of more sophisticated tools that allow to create reports
form WMI queries?
Thank you,
/_urka
Sam Hobbs
2006-01-20 09:56:56 UTC
Permalink
Post by Lurka
I'd like to "extend" the above script to browse through a given list of
machine names
Do you mean the type of scripts in the following?

http://www.microsoft.com/technet/scriptcenter/scripts/templates/default.mspx
Lurka
2006-01-21 21:16:01 UTC
Permalink
Post by Sam Hobbs
Do you mean the type of scripts in the following?
http://www.microsoft.com/technet/scriptcenter/scripts/templates/default.mspx
Yes, something like that.
I'll study them carefully.
Thank you.

Our problem is we have to check the serial number of the displays, too.
I'm afraid that will require manual work in any case.

Getting them through WMI is unlikely.
Even if all displays are now recognized as devices, I suppose
communication with the OS is very limited and many displays may not
even report their serial number in the firmware.

Goodbye,
/_urka

Loading...