Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×
  • entries
    13
  • comments
    3
  • views
    873

Getting the UUID from a running Windows machine, or a computer's AD object


I was having issues with this too using WDS. The UUID is stored in the netbootguid property in the machine's computer object. If you were ever curious enough to want to find out what it is you can use this script:

 

strLDAPComp = "LDAP://CN=machinename,OU=example computers,DC=example,DC=com"

Set objComp = GetObject(strLDAPComp)

Msgbox "AD UUID:" & ConvertObjectGuidToString(objComp.netbootguid)

Function ConvertObjectGuidToString(ByVal arrRawObjectGUID)
     Dim i, strByte
     Dim arrObjectGUID(15)
     For i = 1 To LenB(arrRawObjectGUID)
           strByte = Hex(AscB(MidB(arrRawObjectGUID, i, 1)))
           If Len(strByte) = 1 Then strByte = "0" & strByte
           arrObjectGUID(i - 1) = strByte
     Next
     ConvertObjectGuidToString = Join(arrObjectGUID, "")
End Function

 

To get the UUID from a Windows box (replace the . in the computer name string with a netbios name to get it from a networked Windows box) that is running, you can use this script:

 

'http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.vbscript/2006-07/msg00078.html
'http://araihan.wordpress.com/2010/02/19/how-to-set-computer-naming-policy-in-windows-deployment-services-wds/
'http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_21909382.html

'On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
Msgbox "UUID: " & objItem.UUID
Next

 

I can't take a whole lot of credit for these as they were pieced together from sources around the net. Only the second script had comments in it with sources (it's been a while since I've had to use these). The UUID stored in AD actually has a part of it reversed and that is what the function in the first script fixes to make it human readable.

0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...