You are here:   Research
Register   |  Login
The quickest way to find articles is to use the below search option.

However, if you go to the end of this page, you also find the Blog archive (calendar format) that allows for browsing of older articles.

Search:

Generate Computernames in MDT 2010 based on prefix and a sequencenumber

May 10

Written by:
5/10/2011 11:29 AM  RssIcon

This procedure works like this: If they computername 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 computername based on the prefix and the next sequencenumber.

Step 1- Setting up the Database - detailed step-by-step guide & Video tutorial for this step is available for download in the Videos section - Part 18 of the MDT 2010 Lite Touch - Unleashed series

  1. On the MDT Server (MDT01 in my example), install SQL Server 2008 Express SP1. After installation, enable Named Pipes and restart the service
     
  2. Using the Deployment Workbench, in the advanced node, create a new Database (named MDT in my example)
     
  3. Using SQL Management Studio (Server name is MDT01\SQLEXPRESS), create a Security Login for the domain\user account that you use for your Lite Touch installations
     
  4. For the previously created Security Login, add the following permissions to the MDT Database.
    1. db_datareader
    2. db_datawriter

Step 2 - Add and configure a Stored Procedure + Table for generating computernames based on prefix + sequencenumber. Detailed step-by-step guide & Video tutorial for this step is available for download in the Videos section - Part 19 of the MDT 2010 Lite Touch - Unleashed series

  1. Download the files from here... 
    Generate Computer Names using the MDT Database
     
  2. Using SQL Management Studio, open the InsertComputerNames.sql script and execute it (F5)
     
  3. For the Security Login created in Step 1, grant execute permissions to the IdentifyComputer Stored Procedure (found under Programmability / Stored Procedures)
     
  4. Open the MachineName.sql script and execute it (F5)
     
  5. Edit the MachineNameSequence table, in the prefix field, type in PC, in the sequence field type in 0 (Zero)

Step 3 - Configure the Deployment Share rules

  1. Use the info in the sample customsettings.ini file to configure the rules on your deployment share to use the stored procedure

/ Johan

30 comment(s) so far...


Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Hi Johan,

Thank you for this one.
Can i use this same procedure for both ZTI & LTI?

Cheers

By mdiawara on   5/11/2011 10:39 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Yes, you can

/ Johan

By Arwidmark on   5/12/2011 2:17 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I've setup a full deployment environment following the book guidelines "Deployment Fundamentals - Volume 1" (Arwidmark-Nystrom).

I made only the following change: the bootstrap.ini include only domain name (so username and password are needed to continue). I was able to deploy without problems the images to our test PC. We would like to start the deploy in production environment but I need to generate automaticallyu the name of each PC. For this reason I setup the stored procedure found here but as far as now I was unable to make it work and I even found the reason !

But I cannot fix it; basically the procedure cannot connect to MDT database because it tries to query it using local administrator account (!) instead of the one I've passed at the beginning of deployment (a domain account with privilege over stored procedure). When the OS deployment is finished, in fact, the user logged in is the local administrator (I was expecting instead the domain one used at the begin).

Any ideas ? Why it's using local admin?

These are the errors (found in ZTIGather.log):

Connecting to SQL Server using connect string: Provider=SQLOLEDB;OLE DB Services=0;Data Source=10.6.128.40\SQLEXPRESS;Initial Catalog=MDT;Network Library=DBNMPNTW;Integrated Security=SSPI ZTIGather 28/02/2012 11.24.45 0 (0x0000)
Successfully opened connection to database. ZTIGather 28/02/2012 11.24.46 0 (0x0000)
Only the first MACADDRESS value will be used in the stored procedure call. ZTIGather 28/02/2012 11.24.46 0 (0x0000)
About to issue SQL statement: EXECUTE IdentifyComputer '00:0C:29:D8:3A:4D' ZTIGather 28/02/2012 11.24.46 0 (0x0000)
ERROR - Opening Record Set (Error Number = -2147217887) (Error Description: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.). ZTIGather 28/02/2012 11.24.46 0 (0x0000)
ADO error: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. (Error #-2147217887; Source: Microsoft OLE DB Provider for SQL Server; SQL State: ; NativeError: 0) ZTIGather 28/02/2012 11.24.46 0 (0x0000)
Unable to execute database query. ZTIGather 28/02/2012 11.24.46 0 (0x0000)




By marcomontesanto on   2/28/2012 6:38 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Make sure you have granted the buildaccount execute permissions on the stored procedure itself. read/write to the database is not enough to execute the stored procedure. Also verify that you did add the prefix and a starting sequence number to the machinenamesequence table.

/ Johan

By Arwidmark on   2/28/2012 7:01 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

This is the bootstrap.ini I use; I do not have buildaccount as I've preferred to insert credentials without storing the password in "clear"; could it be the problem ?
________________________________
[Settings]
Priority=Default

[Default]
DeployRoot=\\SERVERNAME\DeploymentShare$

SkipBDDWelcome=YES

UserDomain=MYDOMAIN
UserID=
UserPassword=
______________________________________

By marcomontesanto on   2/28/2012 7:30 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

This is the bootstrap.ini I use; I do not have buildaccount as I've preferred to insert credentials without storing the password in "clear"; could it be the problem ?
________________________________
[Settings]
Priority=Default

[Default]
DeployRoot=\\SERVERNAME\DeploymentShare$

SkipBDDWelcome=YES

UserDomain=MYDOMAIN
UserID=
UserPassword=
______________________________________

By marcomontesanto on   2/28/2012 7:55 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Whatever account you log on with will be used, and that account needs to have execute permissions on the stored procedure itself.

/ Johan

By Arwidmark on   2/28/2012 7:56 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

This is the bootstrap.ini I use; I do not have buildaccount as I've preferred to insert credentials without storing the password in "clear"; could it be the problem ?
________________________________
[Settings]
Priority=Default

[Default]
DeployRoot=\\SERVERNAME\DeploymentShare$

SkipBDDWelcome=YES

UserDomain=MYDOMAIN
UserID=
UserPassword=
______________________________________

By marcomontesanto on   2/28/2012 8:00 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I'm using an administrative account who have "EXECUTE" permission over stored procedure. However I do not pass it using "bootstrap.ini", could be that the account is used only for join to domain (creating MINIT-XXXXXX) and then lost during the next phases ?

By marcomontesanto on   2/28/2012 8:10 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

There is no need to pass it via bootstrap.ini, and the gather action is excuted in the very beginning.

Try run the stored procedure manually in SQL Management Studio, because that fails, the error is SQL related, and not MDT related.

/ Johan

By Arwidmark on   2/28/2012 9:03 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I fix a problem with the stored procedure and now it completes without errors as well as the whole deployment process.
Unfortunately the PC name won't be assigned as I expect and it remains in the format MININT-XXXXX.

When will the stored procedure be invoked ? Should I add a custom task in TS to make it work ?

By marcomontesanto on   2/29/2012 1:57 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I fix a problem with the stored procedure and now it completes without errors as well as the whole deployment process.
Unfortunately the PC name won't be assigned as I expect and it remains in the format MININT-XXXXX.

When will the stored procedure be invoked ? Should I add a custom task in TS to make it work ?

By marcomontesanto on   2/29/2012 2:19 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

The stored procedure is called by the IdentifyComputer section in the customsettings.ini file and the computername is retreived by the CSettings section. The C The ZTIGather.log will show you what settings that where.

/ Johan

By Arwidmark on   2/29/2012 4:28 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Hi Johan, I've been onto this subject for a few weeks and I managed to run the stored procedure successfully. It generates the computer names in the database but the new computer name does not return to the machine being installed. In smstslog it says:
"Successfully queried the database.
Records returned from SQL=1
Value for OSDCOMPUTERNAME is already set to GGN0004 so database value of GGN0016 will be ignored."
What could be wrong here? MDT database didn't have any record about this machine before.

By discontinuity on   3/29/2012 2:19 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Hi Johan, I've been onto this subject for a few weeks and I managed to run the stored procedure successfully. It generates the computer names in the database but the new computer name does not return to the machine being installed. In smstslog it says:
"Successfully queried the database.
Records returned from SQL=1
Value for OSDCOMPUTERNAME is already set to GGN0004 so database value of GGN0016 will be ignored."
What could be wrong here? MDT database didn't have any record about this machine before.

By discontinuity on   3/29/2012 2:58 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Hi Johan, I've been onto this subject for a few weeks and I managed to run the stored procedure successfully. It generates the computer names in the database but the new computer name does not return to the machine being installed. In smstslog it says:
"Successfully queried the database.
Records returned from SQL=1
Value for OSDCOMPUTERNAME is already set to GGN0004 so database value of GGN0016 will be ignored."
What could be wrong here? MDT database didn't have any record about this machine before.

By discontinuity on   3/29/2012 3:18 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

It means you have a previous rule thats sets the computername. Please upload your cs.ini and ztigather.log, and post the link.

/ Johan

By Arwidmark on   3/29/2012 4:36 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

https://skydrive.live.com/#cid=D418489FED312C0C&id=D418489FED312C0C%212137

The first gather step in TS is used to get MAC address and IP address of the machine and to display it in my custom hta where end user selects the appropriate department.
The second gather step is used to get the new computer name. After that another hta displays the new assigned computer name for 10 seconds and the TS continues. But the old name is always assigned though the computer's mac is not in the mdt database. (but the computer that is being installed has computer account in AD and SCCM database. The computer is in the OSD collection that I created.)

I don't know what I'm doing wrong but thank you very much for giving me a hand.

By discontinuity on   3/29/2012 5:22 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

https://skydrive.live.com/#cid=D418489FED312C0C&id=D418489FED312C0C%212137

The first gather step in TS is used to get MAC address and IP address of the machine and to display it in my custom hta where end user selects the appropriate department.
The second gather step is used to get the new computer name. After that another hta displays the new assigned computer name for 10 seconds and the TS continues. But the old name is always assigned though the computer's mac is not in the mdt database. (but the computer that is being installed has computer account in AD and SCCM database. The computer is in the OSD collection that I created.)

I don't know what I'm doing wrong but thank you very much for giving me a hand.

By discontinuity on   3/29/2012 5:23 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

https://skydrive.live.com/#cid=D418489FED312C0C&id=D418489FED312C0C%212137

The first gather step in TS is used to get MAC address and IP address of the machine and to display it in my custom hta where end user selects the appropriate department.
The second gather step is used to get the new computer name. After that another hta displays the new assigned computer name for 10 seconds and the TS continues. But the old name is always assigned though the computer's mac is not in the mdt database. (but the computer that is being installed has computer account in AD and SCCM database. The computer is in the OSD collection that I created.)

I don't know what I'm doing wrong but thank you very much for giving me a hand.

By discontinuity on   3/29/2012 5:23 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Hmm, doing a refresh to see if a new reply has been sent after posting, my browser reposts again!! I'm sorry for the double posts :(

Have you been able to check the logs? I'm still clueless what's going on? If I can't resolve this issue I'll have to find another job :)

By discontinuity on   4/2/2012 9:32 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Well, the computername is already set when the second cs.ini is run, therefor it will not be reset. A workaround is to have the database return another property, say CustomOSDComputerName. Then you can add a "Set Task Sequence Variable" action where you set OSDCOmputerName=%CustomOSDComputerName% which will overwrite whatever that is set.

/ Johan

By Arwidmark on   4/3/2012 12:08 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Thank you very much for the reply. Yes computer has its name assigned (either it's an old computer or a new computer added via computer association in SCCM) before the sql query but I still don't get why it doesn't get overwritten with the new name from sql. Your suggestion is smart, but I don't know how to implement it. If I create a new column in Settings table in MDT database, will that new column's variable be assigned if I create a new TS variable? In that case I should edit the Stored Procedure to update the new column I guess. Any more suggestions Johan? Thank you.

By discontinuity on   4/3/2012 9:38 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I altered the stored procedure so that it inputs the new name to a new column in "settings" table in MDT database. When executed it worked. But I don't know if sql returns that new column's value to the client? Do all the columns' values in "settings" table returned to the client when queried? If so I'm close to the end. Here are the last few line from my stored procedure if it helps.

/* Insert the new record */

INSERT INTO ComputerIdentity (MacAddress)
VALUES (@MacAddress)
INSERT INTO Settings (Type, ID, CustomOSDComputerName, OSDInstallSilent, OSInstall)
VALUES ('C',@@IDENTITY, @NewName, '1', 'Y')

COMMIT TRAN

END

/* Return the record as the result set */

SELECT * FROM ComputerIdentity
WHERE MacAddress = @MacAddress

By discontinuity on   4/3/2012 10:25 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Update: I tried the above method (also created a TS variable like you suggested) but the OSDComputerName variable didn't get its new name from sql. But Sql generates the new name and inputs it in CustomOSDComputerName column. How can we make sql to return this value to the client? Should we alter the last 2 lines in sql stored procedure?
/* Return the record as the result set */

SELECT * FROM ComputerIdentity
WHERE MacAddress = @MacAddress

And how? I'm very sorry for bothering you and sending all these countless posts here :(

By discontinuity on   4/3/2012 11:31 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

No need to inject additional fields

In the customsettings.ini calling your stored procedure, update the [Settings] section to the following:

[Settings]
Priority=IdentifyComputer, Default
Properties=CustomOSDComputername


Update the IdentifyComputer Stored Procedure with the following:
/* Return the record as the result set */

SELECT OSDComputerName AS CustomOSDComputerName FROM ComputerSettings
WHERE MacAddress = @MacAddress

Then add a "Set Task Sequence Variable" action that sets OSDComputerName = %CustomOSDComputerName%. Add this action after the Gather that calls the stored procedure.

/ Johan

By Arwidmark on   4/4/2012 2:37 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I don't know what to say... You can't imagine how much you helped someone you don't know. Thank you very very much Johan, it worked. I've been trying to solve this for weeks. Couldn't find any answer anywhere but this site. And it seems to be working now. You rock! ;) Thank you again and again...

By discontinuity on   4/10/2012 5:13 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

I installed SQL 2012 with MDT 2012 Update 1. This no longer works. It will pull the computer name if it already exists, but it won't write to the computer name. It will create an entry in the DB with the MAC, ID, Type, and OSInstall columns, but not OSDComputerName or Description.

Any ideas?

By marshal.anson on   4/12/2013 7:04 AM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

Yes, send me an email to get the updated stored procedure. My alias is my lastname and I'm using gmail.

/ Johan

By Arwidmark on   4/14/2013 4:47 PM
Gravatar

Re: Generate Computernames in MDT 2010 based on prefix and a sequencenumber

The OSDComputerName is stored in a different table, you should the value when querying the computersettings view (which joins the two tables).

As far as description goes, you need to modify the stored procedure to set the description as well.

/ Johan

By Arwidmark on   5/3/2013 11:40 AM