Here is a stored procedure you can use to generate computer names in MDT 2012/2013, with or without ConfigMgr 2012.
The stored procedure assumes that you have installed the MDT 2012/2013 database, and works like this: If they computer name is in the database already (known), it will assign that name to the PC. If the computer is not in the database (unknown), it will generate a computer name based on the prefix and the next sequence number. The configuration is done in three simple steps:
- Setting up the MDT database
- Add the Stored Procedure and a Table to keep track of the sequence numbers
- Configure the Deployment Share rules (CustomSettings.ini)
Step 1- Setting up the MDT Database
In this example I have a deployment server named MDT01, a deployment share named MDT Production, and I have installed SQL Server 2012 SP1 Express (named pipes enabled). I have also created a Logs$ share to which MDT connects and establishes a trusted connection. To drive my deployments I use an account named VIAMONSTRAMDT_BA (domain user account).
- On MDT01, using Deployment Workbench, expand the MDT Production deployment share, expand Advanced Configuration, right-click Database, and select New Database.
- In the New DB Wizard, on the SQL Server Details page, enter the following settings and click Next:
- SQL Server Name: MDT01
- Instance: SQLEXPRESS
- Network Library: Named Pipes
- On the Database page, select Create a new database; in the Database field, type MDT and click Next.
- On the SQL Share page, in the SQL Share field, type Logs$ and click Next. Click Next again and then click Finish.
- On MDT01, start SQL Server Management Studio.
- In the Connect to Server dialog box, in the Server name list, select MDT01\SQLEXPRESS and click Connect.
- In the Object Explorer pane, expand the Security node, right-click Logins, and select New Login.
- On the Login – New page, in the Login name field, type VIAMONSTRAMDT_BA. Then in the left pane, select User Mapping. Select the MDT database, and assign the following roles:
- public (default)
- Click OK, and close SQL Server Management Studio.
Step 2 – Add and configure a Stored Procedure and Table
- Download the sample files.
- On MDT01, using SQL Server Management Studio, open the InsertComputerNames.sql script and execute it by pressing F5.
- In the left pane (Object Explorer), expand Databases, expand MDT, expand Programmability, and expand Stored Procedures.
- Right-click the dbo. InsertComputerName stored procedure and select Properties.
- In the Stored Procedure Properties – InsertComputerName window, in the left pane, select Permissions. In the right pane, click Search, click Browse, select VIAMONSTRA\MDT_BA, and click OK twice.
- In the right pane, select the Execute check box in the Grant column, and click OK.
- Using SQL Server Management Studio, open the MachineName.sql script and execute it (press F5).
- In the left pane (Object Explorer), in the MDT database, expand Tables.
- Right-click the dbo.MachineNameSequence table and select Edit Top 200 Rows.
- In the Prefix field, type PC, and in the Sequence field, type 80. Then press Enter to insert the record into the database. The number 80 is your starting point, so the first computer will have the name of 80, the next computer will then have a number of 81, and so forth.
Step 3 – Configure the Deployment Share rules
Use the info in the sample CustomSettings.ini file to configure the rules on your deployment share to use the stored procedure.
[Settings] Priority=IdentifyComputer, CSettings, Default [Default] OSInstall=YES [CSettings] SQLServer=MDT01 Instance=SQLEXPRESS Database=MDT Netlib=DBNMPNTW SQLShare=Logs$ Table=ComputerSettings Parameters=UUID, AssetTag, SerialNumber, MacAddress ParameterCondition=OR [IdentifyComputer] SQLServer=MDT01 Instance=SQLEXPRESS Database=MDT Netlib=DBNMPNTW SQLShare=Logs$ StoredProcedure=InsertComputerName Parameters=MacAddress