windows-server-2008 – 修改MDT向导以自动执行计算机命名

前端之家收集整理的这篇文章主要介绍了windows-server-2008 – 修改MDT向导以自动执行计算机命名前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
情况:

I am imaging new systems using MDT Lite-Touch. I am trying to
customize the wizard to automate the naming of new systems so that
they include a prefix “AG-“,a department code which is selected from
a drop-down Box in the wizard page (eg. “FOO”),and finally the
serial number of the computer being imaged,so that my result in this
case would be “AG-FOO-1234567”

状态:

I have banged away at this for a while but my Google searches have not
turned up answers,my trial-and-error is not producing useful error
messages and I think I am missing some fundamentals of how to get
variables from the wizard page into the variables used by the
lite-touch wizard.

进展:

  1. I first created the HTML page which I will include below and added a script to the page to concatenate the pieces into a variable called
    OSDComputername which,for testing,I could output in a msgBox and get
    to display correctly.
    • The problem with this is I don’t know how to trigger the script then assign it to the OSDComputername variable that is used throughout
      the rest of the Light-Touch process.
  2. I changed the script to a function and added it to DeployWiz_Initization.vbs then used the Initialization field in WDS to
    call it. I’ll include the function below.
    • The problem with this is I would get “Undefined Variable” for OSDComputername and I am not sure it is pulling the data from the HTML
      correctly.
  3. I tried adding the scripting into the customsettings.ini file after the “OSDComputername=”
    • This resulted in the wizard just outputting my code in text as the computer name.
  4. I tried adding variables to “Properties=” (eg.DepartmentName) in the customsettings.ini,pulling thier value from the HTML Form and setting that value to the variable in my function in DeployWiz_Initization.vbs and calling them after “OSDComputername=” in the fashion “OSDComputername=”AG-” & %DepartmentName%” in customsettings.ini
    • This resulted in errors from my script which did not correctly access the new variables
  5. I now have my code working. It is pulling the data from the HTML and setting the OSDComputername environment variable. I have updated the code below to match the working code. It is firing correctly and setting my computer name and description exactly as I wanted it to.

问题解决了!

HTML页面

  1. <H1>Configure the computer name.</H1>
  2. <p>Please answer the following questions. Your answers will be used to formulate the computer's name and description.</p>
  3.  
  4. <FORM NAME="SetComputerNameForm">
  5. <p>
  6. <LABEL class="Larger"><u class="Larger">D</u>epartmental Prefix:</LABEL><br />
  7. <SELECT NAME="DepartmentalPrefix_Edit" ID="DepartmentalPrefix_Edit" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=D>
  8. <option value="FOO">FOO</option>
  9. <option value="DOE">DOE</option>
  10. <option value="AFK">AFK</option>
  11. <option value="BBL">BBL</option>
  12. <option value="RTFM">RTFM</option>
  13. </SELECT>
  14. </p>
  15.  
  16.  
  17. <p>
  18. <LABEL class="Larger"><u class="Larger">C</u>lient's ID:</LABEL>
  19. <br />
  20. <INPUT NAME="ClientID" ID="ClientID" TYPE="text" ID="ClientID" SIZE="15" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=C />
  21. <label class=ErrMsg for=ClientID>* required (MISSING)</label>
  22.  
  23.  
  24. </p>
  25.  
  26.  
  27. <p>
  28. <LABEL class="Larger"><u class="Larger">B</u>uilding:</LABEL><br />
  29. <SELECT NAME="Building_Edit" ID="Building_Edit" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=B>
  30. <option value="ASA">ASA</option>
  31. <option value="ASB">ASB</option>
  32. <option value="ASC">ASC</option>
  33. </SELECT>
  34. </p>
  35.  
  36.  
  37. <p>
  38. <LABEL class="Larger"><u class="Larger">R</u>oom Number:</span></LABEL>
  39. <br />
  40. <INPUT NAME="RoomNumber" ID="RoomNumber" TYPE="text" ID="RoomNumber" size="15" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=R>
  41. <label class=ErrMsg for=RoomNumber>* required (MISSING)</label>
  42. </p>
  43.  
  44. </FORM>

功能

  1. Function ValidateSetComputerName
  2. ParseAllWarningLabels
  3.  
  4. If Len(Document.SetComputerNameForm.ClientNetID.Value) < 1 OR Len(Document.SetComputerNameForm.RoomNumber.Value) < 1 THEN
  5. ButtonNext.disabled = true
  6. Else
  7. Dim Department
  8. Dim SerialNumber
  9. Dim CID
  10. Dim RoomNumber
  11. Dim BuildingName
  12. Dim Make
  13. Dim Model
  14. Department = Document.SetComputerNameForm.DepartmentalPrefix_Edit.Value
  15. SerialNumber = oEnvironment.Item("SerialNumber")
  16. CID = Document.SetComputerNameForm.ClientID.Value
  17. RoomNumber = Document.SetComputerNameForm.RoomNumber.Value
  18. BuildingName = Document.SetComputerNameForm.Building_Edit.Value
  19. Make = oEnvironment.Item("Make")
  20. Model = oEnvironment.Item("Model")
  21.  
  22. oEnvironment.Item("OSDComputerName") = "AG-" & Department & "-" & Right(SerialNumber,7)
  23. oEnvironment.Item("ComputerDescription") = Department & "," & CID & "," & RoomNumber & " " & BuildingName & "," & Make & " " & Model
  24. ButtonNext.disabled = false
  25. End If
  26.  
  27. End Function
问题已解决.我已更新上面的代码以反映我所做的更改.

猜你在找的Windows相关文章