Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create computer in AD and add GUID to it 1

Status
Not open for further replies.

AntunB

IS-IT--Management
Aug 11, 2003
263
AU
Hey, i am able to add a computer to AD, but cannot add the GUID to it for remote installations.

i am using

Code:
strGUID = "{00000000-0000-0000-0000-000000000001}"
objComp.Put "netbootGUID", strGUID

but it comes up with an error, i was reading that the string needs to be converted to an octet string or something? how would i do that?

this is using vbscript


thanks
 
>but cannot add the GUID to it
I think it is read-only.
 
nah its not read only, and you can add it

it's just {00000000-0000-0000-0000-000000000001} is the wrong format

i don't know how to convert it??
 
Ok i found a function that makes it work

Code:
'32characters long
strGUID = "00000000000000000000000000000005"

objComp.Put "netbootGUID", getGUID(strGUID)
objComp.SetInfo

Function getGUID(sGUID)
	For iCount = 1 to Len(sGUID) step 2
		aGuid((iCount-1)/2) = "&h" & MID(sGuid, iCount,2)
	Next

	temp = aGuid(7)
	aGuid(7) = aGuid(6)
	aGuid(6) = temp

	temp = aGuid(5)
	aGuid(5) = aGuid(4)
	aGuid(4) = temp

	temp = aGuid(3)
	aGuid(3) = aGuid(0)
	aGuid(0) = temp

	temp = aGuid(1)
	aGuid(1) = aGuid(2)
	aGuid(2) = temp

	getGUID = ConvertGuid(aGuid)
End Function


Function ConvertGuid(Guid)
	'set up the stream as text Latin I
	stream.type = 2 ' text
	stream.charset = "windows-1252" ' Latin I
	stream.open

	'the hex character values to write
	arhex = Guid

	'array(&hfc, &h1c, &h49, &h26, _
	'              &h50, &h9e, &h57, &h48, _
	'              &h86, &h1b, &h0c, &hb8, _
	'             &hdf, &h22, &hb5, &hd7)
	's1 is just to display what hex values are in the array
	'to be written to the stream
	s1 = "" : comma = ""
	for i = 0 to ubound(arhex)
		s1 = s1 & comma & right("0" & hex(arhex(i)),2)
		comma = ","
	next

	'write the hex chars to the stream as text
	for i = 0 to ubound(arhex)
		stream.writetext chr(arhex(i))
	next

	'reposition to the start of the stream
	stream.position = 0

	'toggle to binary stream
	stream.type = 1 ' binary

	'read the entire stream as a byte array
	octetstring = stream.read

	'close the stream since we have what we want...
	s2 = "" : comma = ""
	stream.close

	'prove that we have a byte array
	'wscript.echo typename(octetstring) ' Byte() = byte array
	'build another display string of the bytes in the byte array
	for i = 1 to lenb(octetstring)
		s2 = s2 & comma & right("0" & hex(ascb(midb(octetstring,i,1))),2)
		comma = ","
	next

	'display both to prove they match
	ConvertGuid = octetstring
End Function
 
Thanks AntunB for the correction to my wrong statement. I should have checked and refreshed long chain of detail first. I take note and thanks again.
- tsuji
 
Hey its ok
no one is perfect, and i didnt even have a clue about it....

this was sooo hard to find, but i hope it helps some people out
 
So true, AntunB, especially for me. Have a star on me.
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top