MDT and script problem RRS feed

  • Question

  • Hi, with mdt 2012 update 1, i have a script that change the name of the computer, so the script goes to the active directory looging for a UUID match and name and if he find it he change the name, this scipt work very well with MDT 2012 update 1,

    But with MDT 2013, i cannot make it function properly, so maybe i miss something, in the boot image when I build it, but cannot find what is missing.

    here the script that i got, can someone help me to see what's wrong.

    Thank in advance and sorry for my english :)

    <job id="ZTIConfigure">
    <script language="VBScript" src="ZTIUtility.vbs"/>
    <script language="VBScript">
    oLogging.CreateEntry "changement du nom du serveur en cours...", LogTypeInfo

    On Error Resume Next
    iRetVal = ZTIProcess
    ProcessResults iRetVal
    On Error Goto 0

    Function ZTIProcess
    ZTIProcess = Failure
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    WMIGUID = ""

    If oEnvironment.Exists("UUID") Then
    oLogging.CreateEntry "la variable d'environnement UUID existe...", LogTypeInfo
    If len(oEnvironment.Item("UUID")) > 10 Then
    WMIGUID = oEnvironment.Item("UUID")
    oLogging.CreateEntry "got UUID from Environment " & WMIGUID, LogTypeInfo
    End If
    End If

    If len(WMIGUID) < 10 Then
    Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
    wbemFlagReturnImmediately + wbemFlagForwardOnly)

    For Each objItem In colItems
    WMIGUID = objItem.UUID
    oLogging.CreateEntry "got UUID from WMI " & WMIGUID, LogTypeInfo
    End If

    If oEnvironment.Item("XXXXXX") <> "" then
    adminaccompte= oEnvironment.Item("XXXXXXX")

    End if

    If oEnvironment.Item("XXXXXXXX") <> "" then
    passwordadmin = oEnvironment.Item("XXXXXXXXXX")

    End if

    'MsgBox WMIGUID

    Set oConnect = CreateObject("ADODB.Connection")
    oConnect.Provider = "ADsDSOObject"
    oConnect.Properties("User ID") = XXXXXXXX
    oConnect.Properties("Password") = XXXXXXXXXX
    oConnect.Properties("Encrypt Password") = True

    On error resume next

    oConnect.Open "Active Directory Provider", adminaccompte, passwordadmin
    Set rs = oConnect.Execute("<LDAP://XXXXXXXXXXXXXXXXXXXXXXX")

    For Each E in oConnect.Errors
    oLogging.CreateEntry "conn err desc: " & E.Description, LogTypeInfo
    on error goto 0

    Do While Not rs.EOF
    strServeur = rs.Fields(0).Value
    'MsgBox strServeur

    oLogging.CreateEntry "walking servers... " & strServeur, LogTypeInfo
    strGUID = ADSIOctetStringToHexString(rs.Fields(1).Value)
    If GUIDUnScrambler(strGUID) = WMIGUID Then
    oLogging.CreateEntry "Found a match in AD: " & strServeur, LogTypeInfo
    oLogging.CreateEntry "Setting HostName: " & strServeur, LogTypeInfo
    oEnvironment.Item("HostName") = strServeur
    oLogging.CreateEntry "Setting ComputerName: " & strServeur, LogTypeInfo
    oEnvironment.Item("ComputerName") = strServeur
    oLogging.CreateEntry "Setting OSDComputerName: " & strServeur, LogTypeInfo
    oEnvironment.Item("OSDComputerName") = strServeur
    Exit Do
    End If
    ZTIProcess = Success
    End Function

    Function ADSIOctetStringToHexString(arrbytOctet)
    If lcase(TypeName(arrbytOctet)) = "null" Then
    ADSIOctetStringToHexString = ""
    Exit Function
    End If

    Dim k
    OctetToHexStr = ""
    For k = 1 To Lenb(arrbytOctet)
    ADSIOctetStringToHexString = ADSIOctetStringToHexString & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
    End Function

    Function GUIDUnScrambler(strRawHex)
    GUIDUnScrambler = Mid(strRawHex,7,2)
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,5,2)
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,3,2)
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,1,2)
    GUIDUnScrambler = GUIDUnScrambler & "-"
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,11,2)
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,9,2)
    GUIDUnScrambler = GUIDUnScrambler & "-"
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,15,2)
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,13,2)
    GUIDUnScrambler = GUIDUnScrambler & "-"
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,17,4)
    GUIDUnScrambler = GUIDUnScrambler & "-"
    GUIDUnScrambler = GUIDUnScrambler & Mid(strRawHex,21)
    End Function


    Stephane Gagnon

    Wednesday, February 26, 2014 5:57 PM


All replies

  • There should have been no changes between MDT 2012 Update 1 and MDT 2013 that would have caused a script break like you describe.

    Also note, that Niehaus wrote a Web Service to solve this problem, and I would recommend this:

    Keith Garner -

    Wednesday, February 26, 2014 10:49 PM
  • here an another log that I got during de deployment.

    if we check this log, the script seem able to go see the GUID but after that i've got this error

    ![LOG[changement du nom du serveur en cours...]LOG]!><time="14:29:43.000+000" date="02-18-2014" component="RRQChangeCompName2008" context="" type="1" thread="" file="RRQChangeCompName2008">

    <![LOG[la variable d'environnement UUID existe...]LOG]!><time="14:29:43.000+000" date="02-18-2014" component="RRQChangeCompName2008" context="" type="1" thread="" file="RRQChangeCompName2008">

    <![LOG[got UUID from Environment C44E3C42-DE9F-1CB9-9CB8-4E745DFFA50C]LOG]!><time="14:29:43.000+000" date="02-18-2014" component="RRQChangeCompName2008" context="" type="1" thread="" file="RRQChangeCompName2008">

    <![LOG[conn err desc: Table does not exist.]LOG]!><time="14:29:44.000+000" date="02-18-2014" component="RRQChangeCompName2008" context="" type="1" thread="" file="RRQChangeCompName2008">

    Stephane Gagnon

    Friday, February 28, 2014 3:02 PM