This post is in continuation with Create Automatic ComputerName Part 1 where I demonstrated creating Computer Name when SCCM is integrated with MDT.

In this post, I will be achieving the same results but without MDT integration. Hence, reducing lots of complicacies such MDT Installation, Integration, MDT Toolkit files & MDT Toolkit settings package creation.

In case, if you are looking for a Prompt for computer name during task sequence, you can follow the link.


Replacing MDT Integration with just MDT Lite Package

Thanks to Gerry Hampson who wrote a wonderful article ConfigMgr OSD – use MDT without using MDT, where he has explained beautifully how to avoid MDT package, and just got with just small package which consists of just few files required for generating OSDComputerName.

Pros & Cons of using MDT Lite Package

Pros : If you are just interesting in generating custom variables through CustomSettings.ini and not looking for any other feature MDT, then it is a perfect choice.

Cons: You might not be able to utilize full fledged features of MDT which are User driven installation, full fledged deployment features which MDT has and lots of other features.

Create MDT Lite Package

I am not going to demonstrate how to create the package as it is already documented in ConfigMgr OSD – use MDT without using MDT. However, I will proceed with modifying the CustomSettings.ini.

I will replace the CustomSettings.ini with following content:

[Settings]
Priority=Default,ByVM,ByLP
Properties= ComputerMacAddress
[Default]
OSInstall=Y
SkipCapture=YES
SkipAdminPassword=NO
SkipProductKey=YES
ComputerMacAddress=#Right(Replace("%MacAddress001%",":",""),13)#
[ByVM]
subsection=VM-%IsVM%
[VM-True]
OSDComputername=VM%ComputerMacAddress%
[ByLP]
subsection=LP-%IsLaptop%
[LP-True]
OSDComputername=LP%ComputerMacAddress%

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.

Following example will be used: 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…

Add MDT Lite Package in Task Sequence

Edit existing task sequence, right before Apply Operating System step, add > General > Run Command line.

Name it as MDT Lite and use following command line:

cscript.exe scripts/ZTIGather.wsf /debug:true

Save the task sequence and deploy it on All Unknown Computers Collection.

Simulate the package

You can simulate the real results by running on any system. This gives you flexibility of testing the package (customsettings.ini) before including into the task sequence.

Open cmd prompt, navigate to the MDT Lite folder and run the command:

cscript.exe scripts/ZTIGather.wsf /debug:true

Results will be displayed on command prompt screen only with all variables, rules executed.

This process creates MININT folder under c drive. Navigate to C:\MININT\SMSOSD\OSDLOGS to view ZTIGather.log & also BDD.log.

Note: If you want to run the command again, make sure to delete MININT folder and then execute the command again.

Conclusion

We can achieve generation of Automatic Computer name without integrating MDT with SCCM. Just a small package (MDT Lite) is sufficient for this purpose. If you don’t have any specific needs, you can simply skip integrating MDT with SCCM.