Jump to content


anyweb

How can I easily prompt for a computer name in Configuration Manager 2012

Recommended Posts

Hi Guys...Dani3l

 

I never new you could do variables to add a computer name (cool)......but this is what I use in SCCM 2012 and it works just as it should (Dani3l this works for me)....you can leave it attached to your TS at all times and during OSD time when SCCM database knows the computer name it will bypass this step and it will hold on to it's old name, if it does not know the computer name(out of the box or Unknown) it will prompt you to enter one in....pretty cool..

 

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 standard computer name to continue.", "Computer Name", , 30,30)

oTaskSequence("OSDComputerName") = UCase(sNewComputerName)

wscript.echo "Set Task Sequence variable OSDComputerName to: " & sNewComputerName

Else

wscript.echo "Computer set to receive a standard name, continuing as is."

End If

 

 

 

 

 

Rocket Man

 

Hi Rocket Man,

 

Thanks for your script!

At what time do you execute this in your TS?

 

Do you put this inside a vbs file which you execute through a package?

 

Thanks for some more explanation!

 

Filip

Share this post


Link to post
Share on other sites

Yes you create a package from it. It should be a VBS script so give it a name to suit i:e promptforsystemname.vbs etc...

There is no need to create a program for this package as you will be calling it via a run command Line task.

In the TS editor, attach a run command line task directly after Disk Partitioning and tick the box to add a package (select the promptforsystemname package) and in the command line window enter in promptforsystemname.vbs OR whatever you have called the script.

That's it. Once the disk partitioning is done the script will run and you will be required to enter in a computer name..

 

There are of course other more complex scripts available that have some validation checks (dummy proof) like non special characters allowed, no NetBIOS names may exceed 15 characters etc..

 

There are also other scripts with the use of MDT integration that can auto-name systems to the serial number of the system. This works good on most muti-national vendors but for some vendors it's a pain as some serial numbers are extensively long so the auto-naming fails, but with some script trickery you can overcome this, on most vendors (not them all as I have recently found out).

Share this post


Link to post
Share on other sites

Yes you create a package from it. It should be a VBS script so give it a name to suit i:e promptforsystemname.vbs etc...

There is no need to create a program for this package as you will be calling it via a run command Line task.

In the TS editor, attach a run command line task directly after Disk Partitioning and tick the box to add a package (select the promptforsystemname package) and in the command line window enter in promptforsystemname.vbs OR whatever you have called the script.

That's it. Once the disk partitioning is done the script will run and you will be required to enter in a computer name..

 

There are of course other more complex scripts available that have some validation checks (dummy proof) like non special characters allowed, no NetBIOS names may exceed 15 characters etc..

 

There are also other scripts with the use of MDT integration that can auto-name systems to the serial number of the system. This works good on most muti-national vendors but for some vendors it's a pain as some serial numbers are extensively long so the auto-naming fails, but with some script trickery you can overcome this, on most vendors (not them all as I have recently found out).

 

Hi,

 

I just created the package added it to my TS, but when running it, I got an error: Expected end of statement (Line 17, char 68).

It seems it faulted on the &

 

I now replaced it with a + and am retrying to run the script.

Share this post


Link to post
Share on other sites

Hi guys,

 

I'm having some real problems with this. I'm currently using Config Manager 2012 R2, fully patched. I have a TS setup which deploys to pre-existing clients no problems (it uses their existing computer names), however, unknown computers keep failing. What I've noticed on a new machine when deploying Winodws 8.1 is the following;

  • PXE Boot
  • Select TS
  • Get prompt for OSDComputerName (as previously setup and working in 2012 SP1)
  • Manually specify the machine name
  • TS begins (partitions, applies the image)
  • An 'unknown' device then appears in the All Systems collection
  • After driver packagesare installed I see a screen displaying the Win8 logo and a message saying "Getting Ready"
  • This screens sits there for a long time (on a known machine it goes through very quickly)
  • At some point the machine reboots and displays the "Get Online" screen (as normally shown in OOBE), not a part of the usual TS
  • I click through that and the TS resumes and seemingly completes, however, the machine is not joined to the domain (and I cannot log into it)

On a known machine, using the same TS, it all goes through without issue.

 

I have tried the method used in this article, as well as the vbs script mentioned by Rocket Man as well as the TS variable method mentioned by djkarl - all result in the same failure. I have experienced this on a number of different new machines (we are a school and had a few new models come in this year).

 

Any tips or suggestions would be greatly appreciated!

Edited by Schikitar

Share this post


Link to post
Share on other sites

you can specify a lot of different values using this method, the limit is your imagination and use of variables :)

Share this post


Link to post
Share on other sites

theyssensf and Rocket Man: How can you modify this script so it checks in the AD if the computername is already there?



I use SCCM 2012 SP1 and im trying to make my OSD smarter.




As it is now I use about 12 Device Collections where I put the computers in SCCM in, depending on which Win7 language and which OU they need to go into in the AD. In each of my 12 device collections I have set Collection Variables with OSDDOMAINOUNAME(put computer in correct OU in the AD, OSDInputLocale, OSDSystemLocale, OSDUILanguage and OSDUserLocale (to set correct regional settings depending on which country the computer will go to).



Will it work in a SCCM OSD TS with prompting for OSDComputerName if I set a step in my TS with this script ?

Share this post


Link to post
Share on other sites

This is how our organization prompts for the computername.

 

I'd like to prepopulate the 'value' field to have the servicetag/ serial number.

(referenced step from above)

http://www.windows-noob.com/forums/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=7342

 

The servicetag/ serialnumber is part of our naming convention and having it prepopulated would be 'helpful'.

 

Is this possible? If so, how would I go about doing such.

Thanks in advance.

-Matlock

Share this post


Link to post
Share on other sites

I've seen plenty of posts where this is possible if SCCM is integrated with MDT, which I've done, but have yet to truly dive into the new features.

 

Still trying to determine if this is possible using SCCM only.

Share this post


Link to post
Share on other sites

Here you've got a starting point. This is a simple HTA that asks for a computername. After pressing the button it will be added as a task sequence variable.

<HTML>
<HEAD>
<TITLE>© 2012 - P.T. van der Woude - Inovativ</TITLE>
<HTA:APPLICATION
  APPLICATIONNAME="HTASetComputerName"
  ID="objNewApplication"
  VERSION="0.9.6"
  BORDER="thin"
  MAXIMIZEBUTTON="no"
  MINIMIZEBUTTON="no"
  SINGLEINSTANCE="yes"/>
</HEAD>
<SCRIPT LANGUAGE="VBScript">

Sub Window_OnLoad()
	' Set Window Size and Location
	Window.resizeTo 450,210
	Window.moveTo (screen.width - document.body.clientwidth)/2, (screen.height - document.body.clientheight)/2
	
	' Set TSProgressUI Object
	Set objTSProgressUI = CreateObject("Microsoft.SMS.TSProgressUI")
	objTSProgressUI.CloseProgressDialog()
End Sub

Sub SetOSDComputerName()
	' Set TSEnvironment Object
	Set objTSEnvironment = CreateObject("Microsoft.SMS.TSEnvironment")
	
	' Set Task Sequence Variable OSDComputerName
	objTSEnvironment("OSDComputerName") = newComputerNameBox.value
	
	' Close Window
	Window.Close()
End Sub

</SCRIPT>
<BODY>
    <TABLE BORDER='0' WIDTH='100%' ID='AppTable' STYLE="font:12 pt calibri;table-layout:fixed">
	<TR><TD COLSPAN='2'><img src="Logo_Inovativ.gif" alt="Logo_Inovativ" /></TD><TD COLSPAN='1'><B>Provide a computer name</B></TD></TR>
	<TR><TD ID = 'ComputerNameLabel' COLSPAN='2' VALIGN='top'></TD>
		<TD ID = 'ComputerNameBox' COLSPAN='1'><input type="text" name="newComputerNameBox" size="75" maxLength="15"></TD>
	<TR><TD COLSPAN='2' VALIGN='top'></TD>
		<TD COLSPAN='1'><BUTTON style="width:120;height:25" input id=runbutton name="Ok_button" onClick="SetOSDComputerName">Ok</BUTTON></TD></TR>
	<TR><TD STYLE='font-size:9pt' COLSPAN='2' VALIGN='bottom'><B>Blog:</B> <A HREF="http://www.petervanderwoude.nl">www.petervanderwoude.nl</A></TD>
	<TD STYLE='font-size:9pt' COLSPAN='1' VALIGN='bottom'><B>Twitter:</B> <A HREF="http://twitter.com/pvanderwoude">pvanderwoude</A></TD></TR></TABLE>
</BODY>
</HTML>

Share this post


Link to post
Share on other sites

Thank you Peter.

 

I've stumbled upon the following

 

---
This is a vbs script sets the computername variable to the serial number

---
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
Set env = CreateObject("Microsoft.SMS.TSEnvironment")

For Each objItem in colItems
env("OSDComputerName") = objItem.SerialNumber
Next

 

The next vbs script I found presents a 'computername dialogue box'
-

set env = CreateObject("Microsoft.SMS.TSEnvironment")

Name = inputbox("Enter the name for the new computer" ,"Prompt for Computer Name:",env("_SMSTSMachineName"),400,0)

env("OSDComputerName") = Name

****This prompting script- prepopulates the 'computername' field with the 'current' computer name.
----

I'm trying to combine the two vbs scripts such that in the vbs script which prompts for the computername (that has the current computername prepopulated) instead prepopulates with the serial number.

Given my lack of ability and knowledge of how vbs scripting works, I was hoping the community could help.

 

Thanks for any assistance and guidance.

Share this post


Link to post
Share on other sites

Just wanted to say a quick thanks! :)

I was just looking for a way of prompting an input for a computer name and all I could see was lots of different scripts - there's nothing wrong with scripts but my knowledge on PowerShell is pretty limited so I cant tell if the scripts I've been looking at do what they say they will do and if they do anything else that I dont want them to do!

This was is much easier and simpler than a script so not really sure why all the scripts exist, unless of course this is a new option in 2012/2012R2.

 

Once again, thanks!

B)

Share this post


Link to post
Share on other sites

A bit of old school here, but in the past using Altiris (sorry don't know the version), from the management console, a command to rename the computer could be issued and Altiris would change the computer name, add it to the domain, reboot the system, etc. This feature was very handy for remote offices and when naming standards changed. My organization has moved to SCCM, and I'm surprised SCCM 2012 cannot perform the same feature, or can it?

Share this post


Link to post
Share on other sites

not natively no, you'd have to create a package/program or something similar to do that.

Share this post


Link to post
Share on other sites

Hi All,

 

I'm relatively new to SCCM and this appears to be the simplest way I've found to name a computer using SCCM, but even though the variable shows up in the task sequence and I click on it apply a name it FAILS TO NAME THE DEPLOYED PC. The smsts log shows the precedence = 1, but the when I log into the PC it still shows the reference computer's name. The OSD goes through without a hitch, but I have still been unable to apply a computer name. I think it's important to mention that the OS that is being deployed is a Windows 10 Pro thick image that is being deployed to a vCenter VM. I could really use some help working through this. Thanks in advance.

 

Running ConfigMgr 2012 R2SP2 on VMWare

post-33201-0-42150500-1458329363.png

Share this post


Link to post
Share on other sites

Hi All,

 

I'm relatively new to SCCM and this appears to be the simplest way I've found to name a computer using SCCM, but even though the variable shows up in the task sequence and I click on it apply a name it FAILS TO NAME THE DEPLOYED PC. The smsts log shows the precedence = 1, but the when I log into the PC it still shows the reference computer's name. The OSD goes through without a hitch, but I have still been unable to apply a computer name. I think it's important to mention that the OS that is being deployed is a Windows 10 Pro thick image that is being deployed to a vCenter VM. I could really use some help working through this. Thanks in advance.

 

Running ConfigMgr 2012 R2SP2 on VMWare

 

can you attach the entire smsts.log so we can see what additional actions occur during the ts.

Share this post


Link to post
Share on other sites

Hi Everyone,

This a relatively old post but I see that people (including myself) who are setting up their SCCM infrastructure are asking the same question about setting a ComputerName during the OSD task sequence.

I originally gave the steps a try but it was not working for me in the beginning.

Through another info source on SCCM, I learned that when deploying your OSD TS to All Unknown Computers, you MUST set the deployment type to AVAILABLE and not required. Once I re-deployed to a test PC, voila!! everything started to work as described in the original post.

I'm pretty sure that this important step is not mentioned anywhere in this topic thread so I figured I would add it in case anyone else out there is getting stuck on this too.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...