Automatically generate a Computer's name with MDT Db and customsettings.ini
During the installation we used to prompt for the computer's name, this was completed by the technician. To reduce the possibility of human error we decided to generate the computer's name automatically.
There are different ways to achieve this, we decided to do it like this:
Asset-numbers are assigned to the PC's by our stock-manager and are then scanned/imported in our asset management DB. From this DB we import the assettag and serial number to the MDT dB.
Our computer's names are composed like this:
-PCTYPE-ASSETNUMBER
There are just pctypes:
- Laptop's = LT
- Desktop's = DT
The assetnumber is composed out of 8 digits
- the first 4 digits start from 0000 to 9999
- the last 4 digit are the year the PC was bought: 2011, 2012, etc...
Thus the first installed pc of the year has : 00012011 as asset tag.
A computers name will look like this: LT00012011 or DT00022011
Our custom settings.ini is configured to use the MDT DB, and our deployments are realized through MDT integration in SCCM 2007 R3. In the OSD MDT task sequence the gather (ZTIgather.wsf) step collects a number of variables.
The variables we are going to use are:
- %Islaptop%
- %IsDesktop%
- %assettag%
The first 2 are collected by the gather.wsf script the last one is retrieved from the MDT db.
Using these variables we can automatically generate the computer's name, we just need to make some adjustments (Green) in the Customsettings.ini :
[Settings]
Priority= ByLaptop, ByDesktop, CApps, CAdmins, CRoles, Locations, LSettings, LPackages, LApps, LAdmins, LRoles, MMSettings, MMPackages, MMApps, MMAdmins, MMRoles, RSettings, RPackages, RApps, RAdmins, CPackages, CSettings, Default
Properties=MyCustomProperty
[Default]
OSInstall=Y
SkipAppsOnUpgrade=YES
SkipCapture=NO
SkipAdminPassword=YES
SkipProductKey=YES
[ByLaptop]
subsection=Laptop-%IsLaptop%
[Bydesktop]
subsection=Desktop-%IsDesktop%
[Desktop-True]
OSDComputerName=DT%AssetTag%
[Laptop-True]
OSDComputerName=LT%AssetTag%
I added the values "ByDesktop" and "ByLaptop" to the priority line of the [Settings] section. The priority line is used to establish the sequence in which the process parses the subsections to locate values for the variables. I also added the [ByLaptop] section where I defined the subsection by using the %IsLaptop% variable. I did the same for the [Bydesktop] section with the %IsDesktop% variable.
If the %IsDesktop%/-%IsLaptop% has a value of True the [Desktop-True]/ [Laptop-True] section will set the OSDComputername variable together with the %AssetTag% variablevalue retrieved from the MDT DB.
Lars Verbist