Link to home
Start Free TrialLog in
Avatar of cgooden01
cgooden01Flag for United States of America

asked on

Is there a way to script out gathering the BIOS GUID

Trying to see if there is a way to script out gathering BIOS GUID from a work station?
Avatar of Mark Pavlak
Mark Pavlak
Flag of United States of America image

If you can find the value it would be via a WMI connection to  the win32_Bios class
Avatar of Bill Prew
Bill Prew

Does MS store a GUID for the BIOS? Not sure, but there is also the Universal UID and you can get that by running this
wmic CSProduct Get UUID /format:list

Open in new window

The attached vbscript can poll for the system GUID of the system it's run on.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystemProduct",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_ComputerSystemProduct instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "UUID: " & objItem.UUID
Next

Open in new window

Sorry, mis-typed. That script pulls the UUID from the motherboard, useful if you're using RIS services. I suspect that's what you're after.
Avatar of cgooden01

ASKER

Yes this is what i was needing, the UUID is about the same as the GUID. I was once upon a time very familiar with modifying VB, but apparently not now unfortunately.  Therefore, i would like this piped out to  text file with results and is there a way i can pull all of the machines on my Domain from a specific OU.  
I'll need to work on the script some for text output (it's not really tough but $employer expects something productive today), but as far as running it on only a select OU, set it to run as a startup script.
Try this. It writes the UUID to the same directory from which the script is run with the name of the computer it's run on.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48)
' Open file for Writing
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
For Each objItem in colItems 
	Set MyFile = fso.CreateTextFile(".\" & objItem.Name & "_UUID.txt", True)
Next
' get and write UUID to file
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystemProduct",,48) 
For Each objItem in colItems
    MyFile.WriteLine "UUID: " & objItem.UUID
Next 
' close the config file
MyFile.Close

Open in new window

Works great, now let me ask you this, to finish up this question and task.  Is there a way that  this script can pull UUID from LDAP from all systems in Active Directory.  
ASKER CERTIFIED SOLUTION
Avatar of MidnightOne
MidnightOne
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial