petrosyg
asked on
ComputerName Script during OSD in SCCMwith MDT
I have been using the following Script during my OS deployment... IT works perfectly and meets my needs 90% of the time.
BAsically, it will prompy for a location code and attached a "-" and the "Dell Service tag" Example abc-1234567
What I want to add is when I am using the same PXe boot to a VM, (VMWARE Virtual Desktops), The serialnumber I believe is the mac address and longer than the 15 char limit so my OSD fails during the task sequence.
Does any one has a simple suggestion or fix for this issue?
************************** ********** ********** ********** *******
Dim strComputer, objWMIService, colBIOS, objBIOS, strServiceTag
strComputer="."
Set objWMIService = GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery("S elect SerialNumber from Win32_Bios")
For Each objBIOS In colBIOS
strServiceTag = objBIOS.SerialNumber
Next
Dim sNewComputerName, oTaskSequence, sTSMachineName, bPromptName
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironm ent")
' Get the name the computer is set to receive and truncate to first 6 letters
sTSMachineName = lcase(oTaskSequence("_SMST SMachineNa me"))
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 your Location Code to continue." & vbCrLf & _
"The name will be set to XXX-" & strServiceTag & vbCrLf & _
"where XXX is the location you enter.", "Computer Location", , 30,30)
oTaskSequence("OSDComputer Name") = 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
************************** ********** ********** ********** ********** *******
BAsically, it will prompy for a location code and attached a "-" and the "Dell Service tag" Example abc-1234567
What I want to add is when I am using the same PXe boot to a VM, (VMWARE Virtual Desktops), The serialnumber I believe is the mac address and longer than the 15 char limit so my OSD fails during the task sequence.
Does any one has a simple suggestion or fix for this issue?
**************************
Dim strComputer, objWMIService, colBIOS, objBIOS, strServiceTag
strComputer="."
Set objWMIService = GetObject("winmgmts:{imper
Set colBIOS = objWMIService.ExecQuery("S
For Each objBIOS In colBIOS
strServiceTag = objBIOS.SerialNumber
Next
Dim sNewComputerName, oTaskSequence, sTSMachineName, bPromptName
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironm
' Get the name the computer is set to receive and truncate to first 6 letters
sTSMachineName = lcase(oTaskSequence("_SMST
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 your Location Code to continue." & vbCrLf & _
"The name will be set to XXX-" & strServiceTag & vbCrLf & _
"where XXX is the location you enter.", "Computer Location", , 30,30)
oTaskSequence("OSDComputer
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
**************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
David, Great tip and thank you for all your help --- it worked !!
ASKER
Thank you kindly,
Petros