Jeroen de Vroede was kind enough to provide his solution for store and retreive productkeys in the MDT database. Credits also goes to Rune Bakken and Ulrik Skadhauge Jensen for some of the stored procedure work.
In his own words:
– I was trying to add functionality to the Stored Procedure that I could store and retreive productkeys. I work for a small company that uses OEM keys and it would be very nice to store the installation keys in the MDT database.
The solution is based on a few components
- CreateComputer – a stored procedure that generates a computer name based on prefix and a sequence number, and adds the computer to the database. The CreateComputer stored procedure will only add the computer to the database if it does not exist already in the database, and there is also logic in the CreateComputer stored procedure to assign different OU's depending on the machine being a laptop or desktop.
- UpdateComputerInformation – a stored procedure that updates existing computers with serialnumber or macaddress and the product key.
- MachineNameSequence – a table that keeps track of the generated computer names.
- UpdateDB – a customsettings.ini file (named UpdateDB.ini) with instructions to call the UpdateComputerInformation stored procedure.
Step-by-step guide to implement the solution
These steps assume that you already have a working MDT database and have assigned read and write permission for the account you are using in the deployment process.
- Using Management Studio, execute the three SQL scripts, they will create the stored procedures and the table. If your MDT database is not named MDT, you need to change the SQL scripts to reflect that.
- Grant execute permissions to the stored procedures for the account you are using in the deployment process. The account should already have read and write permissions to the MDT base.
- Edit the MachineNameSequence table and type in a prefix and a starting number for the sequence.
- Copy the Updatedb.ini file to your deployment share control folder
- In the task sequence, create another Gather step under the Validate group, configure it to Gather local data and process rules, and to use the UpdateDB.ini file.
The Task Sequence with the extra Gather step added
- Update your customsettings.ini with the below rules (or copy from the sample customsettings.ini in the download).
[Settings] Priority=CreateComputer [CreateComputer] SQLServer=MDT01 Instance=SQLEXPRESS Database=MDT Netlib=DBNMPNTW SQLShare=MDTLogs StoredProcedure=CreateComputer Parameters=MacAddress, SerialNumber, IsLaptop, IsDesktop
Make sure that your customsettings.ini is configured to prompt for the product key (SkipProductKey=NO)
That's it 🙂