There are several other blogs out there explaining how to do this in MDT 2010. They work fine since there is not that big a difference in MDT 2012!
Since I am a Configuration Manager guy, I like to use the ConfigMgr Task Sequence rather than the MDT. So I thought I could show how to use the MDT db in a Configmgr 2012 SP1 Task Sequence and also using a ConfigMgr boot image.
The short version for those who has done this before, but do not remember all the steps see Johan Arwidmark’s blog http://www.deploymentresearch.com/Blog/tabid/62/EntryId/24/Generate-Computernames-in-MDT-2010-based-on-prefix-and-a-sequencenumber.aspx
This is the one that I’ve used as a base for this blogpost, but he only uses MDT and SQL. When using Configuration Manager so there is a few differences.
First, let’s set enable Named Pipes in SQL. By default this protocol is disabled. To enable it start the SQL Server Configuration Manager and expand the SQL Server Network Configuration. Click protocols… and enable Named Pipes. You’ll get a pop up telling you to restart the SQL Server Service. Do so before continuing.
You may use TCP/IP, but then you’ll need to use a SQL user account to connect to the database rather then using a domain user account with Named Pipes.
Now open the MDT Workbench. If you haven’t created a deployment share do so and give it a share name. I used the default DeploymentShare$.
Expand the folderstructure and create a new database.
Follow the wizard. If you use the default SQL instance you do not need to specify the instance name or the port. 🙂
You can use the same share we created during the deployment share creation wizard or another if you want. This is used for authentication during the task sequence when connecting to the sql db.
The database is now created. Close the MDT workbench and start SQL Management Studio to add a new login.
This is the user that you use during your task sequence. The Network Access Account. My is named SVC-CM-NA.
Edit the user mappings on the new login account and add “db datareader” and “db datawriter” on the MDT database.
Copy the sample files to a local folder and open the stored procedures from the SQL Management Studio.
If you download the files from Johan Arwidmark, you will need to edit the “IdentifyComputer.sql” file.
drill down till you find the section:
Delete the framed text before you run it. Otherwise it will fail. This column is no longer used. (Michael Niehaus blog: Database changes in MDT 2012 and MDT 2012 Update 1 http://blogs.technet.com/b/mniehaus/archive/2012/09/09/database-changes-in-mdt-2012-and-mdt-2012-update-1.aspx)
I have already done this in the sample files attached to this post. 🙂
Run the InsertComuterNames stored procedure by clicking “Execute” or push F5.
Now you need to set execution permissions to the “IdentifyComputer”.
Open the second SQL stored procedure labeled “LocationLookup.sql” and execute (click “Execute” or push F5).
Almost done with the SQL stuff.
Edit the table “MachineNameSequence” and set your desired prefix and what number the sequence should start counting from. Usually 0 (zero), then your first computer will get the computername EVRY0001
If you edit the file “IdentifyComputer.sql” and scroll down to the line “SET @NewName = @Prefix + Right(‘0000’+LTrim(Str(@Sequence)),4)”, you can edit how many number you want in your sequence.
Close the SQL Management Studio.
Edit your CustomSettings.ini file and add the following sections to it.
To be able to use this in a Configuration Manager 2012 task sequence there are a few simple steps you’ll have to perform.
Edit you task sequence and add the two MDT steps needed.
In the Gather step refer to your CustomSettings.ini file
As I said, I like to use Configuration Manager as much as possible. Therefore we need to add a component to our boot image.
This only has to be done to your x86 boot image.
You need to add a database component. If you miss this step you task sequence will fail while trying to connect to the MDT db!
Remember to update you distribution points for all changed packages!
Good luck 🙂