View RSS Feed


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

Rate this Entry
by , 25th September 2012 at 04:27 PM (6468 Views)
Quote Originally Posted by Duke5A View Post
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
      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:


'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
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.
VB Script



Total Trackbacks 0
Trackback URL: