locked
Creating a computer account in AD and setting its netbootGUID RRS feed

  • Question

  • Hi guys!

    Using Quest's AD cmdlets I'm able to create pretty easily a computer account in my AD, however what I haven't been able to do so far is to set this computer account netbootGUID.
    Below are a few additional information and the commands I tried:



    GUID of the computer to install as given by PXE: 564DC5C5F4741D839F1CC16FEA324DEC
    With the dashes: 564DC5C5-F474-1D83-9F1C-C16FEA324DEC
    In the ADSI format: C5C54D56-74F4-831D-9F1C-C16FEA324DEC


    First attempt to prestage the computer account with a byte array (I tried with the two different value orders):
    [Byte[]]$array = @(0x56,0x4D,0xC5,0xC5,0xF4,0x74,0x1D,0x83,0x9F,0x1C,0xC1,0x6F,0xEA,0x32,0x4D,0xEC)
    new-qadObject -ParentContainer 'OU=PCs,DC=uat,DC=tld' -type 'computer' -name 'TestPC' -ObjectAttributes @{sAMAccountName='TestPC';netbootGUID=$array}

    Error >> New-QADObject : A constraint violation occured. (Exception from HRESULT: 0x8007202F)


    Next attempt directly with the string:
    [GUID]$guid = "564DC5C5-F474-1D83-9F1C-C16FEA324DEC"
    new-qadObject -ParentContainer 'OU=PCs,DC=uat,DC=tld' -type 'computer' -name 'TestPC' -ObjectAttributes @{sAMAccountName='TestPC';netbootGUID=$guid}

    Error >> New-QADObject : Unspecified error

    I also tried with
    [GUID]$guid = "564DC5C5F4741D839F1CC16FEA324DEC"
    [GUID]$guid = "C5C54D5674F4831D9F1CC16FEA324DEC"
    [GUID]$guid = "C5C54D56-74F4-831D-9F1C-C16FEA324DEC"



    Does anyone know what format should be used?

    Thank you!
    Thursday, August 13, 2009 2:03 PM

Answers

  • Hi everyone,

    I finally got it to work using .NET :)
    I programmed a little tool that is able to set the netbootGUID. Here's a snippet of code that will do the job:

    DirectoryEntry entry = new DirectoryEntry("LDAP://" + adpath, user, password, AuthenticationTypes.Secure);
    DirectoryEntry computer = entry.Children.Add("CN="+name, "computer");
    computer.Properties["sAMAccountName"].Value = name;
    string guid = "C5C54D56-74F4-831D-9F1C-C16FEA324DEC";
    Guid g = new Guid(guid); computer.Properties["netbootGUID"].Add(g.ToByteArray()); computer.Properties["userAccountControl"].Value = 0x00001000; computer.CommitChanges();


    Thanks for everyone's help!
    • Marked as answer by Thibault B. _ Monday, August 17, 2009 7:10 AM
    • Edited by Thibault B. _ Monday, August 17, 2009 7:11 AM code layout
    Monday, August 17, 2009 7:10 AM

All replies

  • Have you tried simply passing $guid as a plain string?

    Since this is the Quest AD cmdlets, you'll likely get better support from the www.powergui.org forums where all the cool Quest guys hang out.
    • Proposed as answer by Marco Shaw Thursday, August 13, 2009 3:18 PM
    • Unproposed as answer by Thibault B. _ Monday, August 17, 2009 7:12 AM
    Thursday, August 13, 2009 3:18 PM
  • I also tried that, but it didn't work either :S I will post on powergui.org as well, thanks.
    Thursday, August 13, 2009 3:30 PM
  • This property takes an octet string

    the GUID object has an ToByteArray() method that gives a byte array we can cast that to a string arry by using  [string[]]

    so this would look like this

    $pc.netbootGUID = [string[]]([guid]'00000000-0000-0000-0000-000000000000').ToByteArray()
    $pc.setinfo()

    Greetings MOW
    Thursday, August 13, 2009 3:48 PM
  • I tried your solution a____o____ however I got the same result.
    The commands I typed:



    Did I miss something?

    Thanks
    Thursday, August 13, 2009 5:34 PM
  • Hi everyone,

    I finally got it to work using .NET :)
    I programmed a little tool that is able to set the netbootGUID. Here's a snippet of code that will do the job:

    DirectoryEntry entry = new DirectoryEntry("LDAP://" + adpath, user, password, AuthenticationTypes.Secure);
    DirectoryEntry computer = entry.Children.Add("CN="+name, "computer");
    computer.Properties["sAMAccountName"].Value = name;
    string guid = "C5C54D56-74F4-831D-9F1C-C16FEA324DEC";
    Guid g = new Guid(guid); computer.Properties["netbootGUID"].Add(g.ToByteArray()); computer.Properties["userAccountControl"].Value = 0x00001000; computer.CommitChanges();


    Thanks for everyone's help!
    • Marked as answer by Thibault B. _ Monday, August 17, 2009 7:10 AM
    • Edited by Thibault B. _ Monday, August 17, 2009 7:11 AM code layout
    Monday, August 17, 2009 7:10 AM
  • Hi,

    Glad to hear you have resolved the problem. Thank you for your sharing, it’s helpful.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, August 17, 2009 9:05 AM