Imagine yourself with the following requirements when deploying Windows clients:
- Computer objects are pre-staged prior to deployment
- The naming convention is the computer’s asset tag with additional characters (in this particular example, it is CI<asset tag>)
The solution I was looking for was having the OSDComputerName variable populated with the naming convention. It would allow me not to care anymore if I was deploying to known or unknown computers (from a Configuration Manager). Having the objects pre-staged allowed not to care anymore for any OU related configuration or assignment.
I knew that it’s possible to have the OSDComputerName variable populated with information by using scripts. In the past it was done by .vbs scripts. But today we have PowerShell which can be used in a Windows PE environment if the boot image has the Windows PowerShell module loaded. So I started looking.
I quickly got to Nickolaj Andersen’s blog (again J) and I found exactly what I was looking for at the following blog post:
I’d like to thank Nickolaj for this little gem and all the credits go to him.
Fortunately, in my case I don’t make difference between a desktop or a laptop. Someone in the comments created a simplified script which would do the trick for me. I created a .ps1 file which contains the following cmdlets:
$SerialNumber = (Get-WmiObject -Class Win32_BIOS | Select-Object SerialNumber).SerialNumber
$OSDComputerName = “CI” + $SerialNumber
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$TSEnv.Value(“OSDComputerName”) = “$OSDComputerName”
After following the instructions displayed in Nickolaj’s post, I was able to successfully populate the OSDComputerName variable which meets the naming convention. Knowing the computer objects are pre-staged I’m able to deploy a Task Sequence to the ‘unknown computers’ without doing anything extra, great for migration purposes (especially when migrating to a pristine Active Directory forest). So no manual OSDComputerName prompt required.
So if the naming convention contains the asset tag, then you can try this out yourself. In a test environment first, that is…