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
Next
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
Next
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
rs.MoveNext
Loop
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)
Next
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
</script>
</job>
Stephane Gagnon