If you can't read please download the document
Upload
hakhanh
View
215
Download
0
Embed Size (px)
Citation preview
OSD Front End Script
' '***********************************************************
' '***********************************************************
'
' Operating System Deployment Front End Script
'
' Author: Jarvis Davis
' verbalprocessor.com
'
' Creation Date: March 16, 2009
'
' Purpose: To provide a method for entering data that the OSD process will use
' to customize the OSD process. Specifically this will provide:
' 1. Automated and custom computer naming.
' 2. User name to add to local admin group
' 3. Location choice which will determine the AD OU utilized.
' 4. Ability to install Role Based apps
' 5. Ability to remove Role Based Apps
'
' Assumptions: 1. Automated computer name is based off of the BIOS S/N. The BIOS
' field used below is valid for Lenovo workstations.
' 2. Windows PE must have HTA and ADO support. This is most easily
' accomplished by using MDT integration to create a new boot image.
'
' Acknowledgements: I am indebted to Johan Arwidmark and Neil Peterson for their blog
' posts about Front End HTA scripts. I learned from them and massaged
' some of their code in creating this script. It is impossible for me
' in hindsight to determine which portions are my own creation and which
' are primarily theirs.
'
'***********************************************************
' General Flow:
' * Initial HTA will need to have the "Computer Name" button pressed to query WMI for the automated computer name.
' * If a computer name is entered, the suggested name (created with the button) is ignored.
' * The computer name is placed in the OSDComputerName TS variable.
' * The location drop down is used to set the value of the OSDDomainOUName variable.
' * The Role Based App checkboxes sets the value of variables to either true or false. These values are used
' * on the "Options" tab of "Install Software" task sequences to determine whether to execute or not.
' * The value of OSDUserName is used by the back end script to add the indicated user to the local admin group on the workstation.
'***********************************************************
'
'
' NOTE: This script is provided as a sample only and under no circumstances should it be used in a live environment.
'
'
'***********************************************************
'***********************************************************
' Set objects and declare global variables
Set env = CreateObject("Microsoft.SMS.TSEnvironment")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
DIM strCompName
DIM strCompSNdisplay
DIM strOU
strCompSNdisplay = ""
strCompName = ""
Sub Window_onLoad
window.resizeTo 400,425 ' Resize the HTA window on first load
window.moveTo 150, 150 ' Move the window to the center
' Pull the Serial Number from BIOS via WMI and put it in a global variable.
' Show it on the screen as a suggested computer name.
For Each objSMBIOS in colSMBIOS
strCompSNdisplay = objSMBIOS.SerialNumber
strCompSNdisplay = cstr(strCompSNdisplay)
' strCompSNdisplay = "L" & strCompSNdisplay ' Utilize a line such as this to prepend to the S/N to match naming standards.
List.InnerHTML = "Suggested Computer Name(modify if desired):
"
Next
End Sub
Sub ButtonFinishClick
' ButtonFinishClick is executed by the "Finish" button.
' Set value of variable to true/false based on whether the checkbox is selected or not
If Project2007.Checked Then
strProject2007 = "true"
else strProject2007 = "false"
End If
' Set value of variable to true/false based on whether the checkbox is selected or not
If Visio2007.Checked Then
strVisio2007 = "true"
else strVisio2007 = "false"
End If
' Set value of variable to true/false based on whether the checkbox is selected or not
If RemoveAudacity.Checked Then
strRemoveAudacity = "true"
else strRemoveAudacity = "false"
End If
' Determine what the computer name should be.
If ("" & ComputerName.Value = vbNullString) Then ' Check to see if anything has been entered in the computer name field
Msgbox "You must enter a computer name. Restart the deployment.",0,"Error" ' Display an error message.
set objShell = CreateObject("WScript.Shell") ' Reboot Windows PE
objShell.Run ("wpeutil reboot")
else strCompName = ComputerName.Value ' If a computer name has been entered, use that value.
strCompName = cstr(strCompName)
End If
' Set value of variables that will be used by the task sequence, then close the window and allow the task sequence to continue.
env("OSDUserName") = Username.Value
env("OSDDomainOUName") = strOU
env("OSDProject2007") = strProject2007
env("OSDVisio2007") = strVisio2007
env("OSDRemoveAudacity") = strRemoveAudacity
env("OSDComputerName") = strCompName
window.Close
End Sub
' Set value of variable based on the selection in the drop down list.
Sub SubOU
If Optionchooser.Value "Choose" Then
strOU = Optionchooser.Value
End If
End Sub
Username to add to Local Admin Group:
(Don't include the domain name.)
Computer OU:
Choose
Default OU
Other Workstations OU
Role Based Applications:
Install Microsoft Project 2007
Install Microsoft Visio 2007
Remove Audacity
Finish