Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


create computer in AD and add GUID to it

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3025
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> create computer in AD and add GUID to it
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 create computer in AD and add GUID to it - 5/16/2005 6:31:00 PM   
  antun

 

Posts: 9
Score: 0
Joined: 4/20/2005
From:
Status: offline
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
[/CODE]

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
 
 
Post #: 1
 
 Re: create computer in AD and add GUID to it - 5/17/2005 1:24:05 PM   
  antun

 

Posts: 9
Score: 0
Joined: 4/20/2005
From:
Status: offline
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
[/CODE]

(in reply to antun)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> create computer in AD and add GUID to it Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts