<Condition><![CDATA[UCase(Property("SkipComputerName"))<>"YES" and Property("DeploymentType")<>"REPLACE" and Property("DeploymentType")<>"UPGRADE" and Property("DeploymentType")<>"CUSTOM" and Property("DeploymentType") <> "StateRestore"]]></Condition>
<Initialization><![CDATA[InitializeComputerName]]> </Initialization>
<Body>
<![CDATA[
<H1>Configure the computer name.</H1>
<span style="width: 95%;">
<p><span class="Larger">Enter the <u class=larger>l</u>ocation for this computer:</span>
<select id="OSDComputerLocation" name=OSDComputerLocation size=1 language=vbscript onpropertychange=ValidateComputerLocation AccessKey=l>
<option id="--select--" value="--select--"> -- Select -- </option>
<option id="ABC" value="ABC">ABC</option>
<option id="DEF" value="DEF">DEF</option>
<option id="GHI" value="GHI">GHI</option>
</select></p>
<p><span class="Larger">Computer n<u class=larger>a</u>me:</span>
<input type=text id="OSDComputerName" name=OSDComputerName size=15 language=vbscript onpropertychange=ValidateComputerName AccessKey=A /></p>
<p>
<label class=ErrMsg for=OSDComputerName>* Required (MISSING)</label>
<label class=ErrMsg id=InvalidChar>Letters, Numbers & Dashes only!</label>
<label class=ErrMsg id=TooLong>Maximum of 15 characters!</label>
</p>
<!-- Computer Description Format -->
<!--
<p>You can also give your computer a friendly description. Unlike the computer
name, the computer description may contain spaces and other special characters. "Frank Kim's Test machine" and
"E-Mail Server #23, Miami Regional Office, Rm. 2305." are examples of computer descriptions.</p>
<p><span class="Larger">Computer <u class=larger>d</u>escription:</span><br/>
<input type=text id="Description" name=ComputerDescription size=60 language=vbscript onpropertychange=ValidateComputerName AccessKey=d /></p>
-->
</span>
]]>
</Body>
<Validation><![CDATA[ValidateComputerName]]></Validation>
'''''''''''''''''''''''''''''''''''''
' Validate Computer Location : CUSTOM FUNCTION
'
Function ValidateComputerLocation
' Check Warnings
ParseAllWarningLabels
If OSDComputerLocation.value = "--select--" then
InvalidChar.style.display = "none"
TooLong.style.display = "none"
OSDComputerName.value = ""
ValidateComputerLocation = False
ButtonNext.disabled = true
Else
Dim strComputer, objWMIService, colBIOS, objBIOS, strServiceTag, bIsLaptop, bIsDesktop, bIsServer, sAutoComputerName, colEnclosure, objInstance
strComputer="."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery("Select SerialNumber from Win32_Bios")
For Each objBIOS In colBIOS
strServiceTag = objBIOS.SerialNumber
Next
bIsLaptop = False
bIsDesktop = False
bIsServer = False
sAutoComputerName = ""
Set colEnclosure = objWMIService.ExecQuery("Select ChassisTypes from Win32_SystemEnclosure")
For Each objInstance In colEnclosure
If objInstance.ChassisTypes(0) = 12 Or objInstance.ChassisTypes(0) = 21 then
' Ignore docking stations
Else
Select Case objInstance.ChassisTypes(0)
Case "8", "9", "10", "11", "12", "14", "18", "21"
bIsLaptop = true
Case "3", "4", "5", "6", "7", "15", "16"
bIsDesktop = true
Case "23"
bIsServer = true
Case Else
' Do nothing
End Select
End If
Next
'If bIsLaptop = True Then
' sAutoComputerName = "N" & OSDComputerLocation.value & strServiceTag
'ElseIf bIsDesktop = True Then
' sAutoComputerName = "D" & OSDComputerLocation.value & strServiceTag
'ElseIf bIsServer = True Then
' sAutoComputerName = "S" & OSDComputerLocation.value & strServiceTag
'End If
sAutoComputerName = OSDComputerLocation.value & "-" & strServiceTag
OSDComputerName.value = sAutoComputerName
oEnvironment.Item("OSDComputerName") = OSDComputerName.Value
ValidateComputerLocation = True
InvalidChar.style.display = "none"
TooLong.style.display = "none"
End If
End Function
Dim strComputer, objWMIService, colBIOS, objBIOS, strServiceTag
strComputer="."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery("Select SerialNumber from Win32_Bios")
For Each objBIOS In colBIOS
strServiceTag = objBIOS.SerialNumber
Next
Dim sNewComputerName, oTaskSequence, sTSMachineName, bPromptName
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
' Get the name the computer is set to receive and truncate to first 6 letters
sTSMachineName = lcase(oTaskSequence("_SMSTSMachineName"))
If left(sTSMachineName,6) = "minint" Then
bPromptName = True
ElseIf sTSMachineName = "minwinpc" Then
bPromptName = True
Else
bPromptName = False
End If
' Note: The wscript.echo commands are logged in SMSTS.log for troubleshooting. They are not displayed to the end user.
If bPromptName = True Then
wscript.echo "Detected that the computer name is scheduled to receive a random value. Prompting user to input a standard name."
sNewComputerName = InputBox ("Please enter a location to continue." & vbCrLf & _
"The name will be set to XXXX-" & strServiceTag & vbCrLf & _
"where XXXX is the location you enter.", "Computer Location", , 30,30)
oTaskSequence("OSDComputerName") = UCase(sNewComputerName & "-" & strServiceTag)
wscript.echo "Set Task Sequence variable OSDComputerName to: " & sNewComputerName & "-" & strServiceTag
Else
wscript.echo "Computer set to receive a standard name, continuing as is."
End If
One question, when you say the ending four numbers are not to be otherwise used in AD, do you mean the number as a whole, regardless of the department, or is the same number, but different departments, allowed?
Regards,
Rob.