In this post I will be demonstrate you how to create automatic computer during during OSD through SCCM. Without having any logic for the Computer name generation, random system name will be generated starting with MININT and with some other random string.
- How can we generate computer Name through Operating System Deployment ?
- Example we are going to use: Virtual Machine(VM+MacAddress,LT+MacAddress)
- Preparation required
- Creation of MDT packages
- Modify CustomSettings.ini
- Edit your existing Task Sequence
- Run the task sequence
How can we generate computer Name through Operating System Deployment ?
To generate the Computer Name automatically, we can use the power of customsettings.ini which will contain the OSDCOMPUTERNAME variable few customization.
This file can be customized based upon our choice regarding how we want to generate the system name.
In case, if you are looking for a Prompt for computer name during task sequence, you can follow the link.
Example we are going to use: Virtual Machine(VM+MacAddress,LT+MacAddress)
Let’s say, we need to generate the system name based upon virtual machine starting with VM, and Laptop starting with LP. Remaining 13 characters will consist of Mac Address.
While applying operating system, there is a variable called OSDCOMPUTERNAME which gets generated automatically while deploying the OS, but if we the same variable generated automatically through customsettings.ini, it will override default random value which usually start with MININT…
- You need to have to MDT Integrated with SCCM
- You need to have MDT File Package & MDT Settings Package
Creation of MDT packages
There are two packages required for this purpose:
1. MDT Files Package: Package consists of all MDT scripts
2. MDT Settings Package: Consists of CustomSettings.ini & Unattend.xml file.
Convenient way of creating this package is to create MDT Task Sequence. When we follow the wizard for creating MDT Task Sequence, this will prompt for creating both the packages, and you will get this created automatically.
This is how MDT file package will look like with folders such as $OEM$, Applications, Packages, Scripts etc.
Scripts folder will contain all the required scripts for MDT.
This is how MDT Settings package will look like and default values under CustomSettings.ini will be:
Now it is the time to modify CustomSettings.ini. Delete all the previous content and paste it with following:
Let’s understand CustomSettings.ini
CustomSettings.ini consists of 2 major section.
Priority – These are sections under file and shows in which order it applied. Or we can say as rules defined and the order of applying those rules. The one on the left applies first. In this case, starting with Default as top priority, then ByVM and ByLP. ByVM and ByLP is our custom defined rules.
Properties – These are the custom variables which is going to be part of the rule such as Default,ByVM etc.
We are creating ComputerMacAddress property (variable) which will consist of last 13 digits of MacAddress. MacAddress001 is the inbuilt variable of MDT. Hence, we are shortening the length and removing colons(:) out of it.
Priority ByVM is custom name created by us, we could have used any name ByVM,ByVMtype,ByVirtual etc.
When ByVM rule is about to run, it will check for any existing rule. We have another rule under it ie. VM-%IsVM%.
%IsVM% is inbuilt MDT variable, which have 2 values: True or False.
If system is Virtual, it will generate value True, hence our next rule becomes true to run ie. VM-True
VM-True consists of OSDComputername=VM%ComputerMacAddress%.
We are creating OSDComputername variable which consists of VM + last 13 digits of Mac Address.
The same logic is applied for BYLP rule to create LP+ Last 13 digit of Mac Address has OSDCOMPUTERNAME.
Note: There is a hug list of MDT variables such as IsDesktop, IsModel, IsTPM, IsUEFI, JoinDomain, DomainAdmin etc.
You can follow MDT toolkit reference for all variables.
Edit your existing Task Sequence
This is my existing task sequence where I added only 2 steps ie. Use Toolkit Package & Gather.
If SCCM is integrated with MDT, then you will get MDT menu to add Use Toolkit Package. Select the package which was previously created.
Add Gather step through MDT menu. Specify Rule file as CustomSettings.ini.
Run the task sequence
We are ready to run the task sequence as everything is in place. Deploy Task Sequence on Unknown Computers. I did PXE boot and selected the task sequence.
Even before TS is completed, I can verify if I am getting appropriate results.
Press F8 to bring cmd prompt and open the ztigather.log by running the following command:
Cmtrace.exe x:\windows\temp\SMSTSLog\ZTIGather.log and we can the values generated as expected:
Once the build is completed, we can verify the same that hostname has the desired format what were looking for.
We can see how conveniently we can generate the computer Name based upon MDT inbuilt variables and our own sense of generating custom variables based upon the requirement.
In Part 2, I have demonstrated the same results where we can completely avoid MDT installation and integration.