In assisting a recent customer implement an upgrade from WinXP to Win7, they requested that the names be changed to fit a new standard as part of the in-place imaging process. In this particular case, all of the computers had a name that ended with a sequential number (1, 2, 3, …) plus an “A” tacked on at the end. They wanted the “A” removed and for the PC name just to end with the sequential number.
This was a pretty easy fix to accomplish through a VBScript which
- Retrieves the active OSDComputerName task sequence variable
- Detects if the last letter is an “A”
- Truncates the name to remove the “A”
- Re-sets OSDComputerName to the new value
'========================================================================== ' NAME: PCNameStandardization.vbs ' AUTHOR: Nick Moseley, <a href="https://t3chn1ck.wordpress.com">https://t3chn1ck.wordpress.com</a> ' COMMENT: This script will detect if the current computer name ends with ' the letter 'A' so that it can be removed. '========================================================================== Option Explicit Dim oTaskSequence, sComputerName, iNameLength Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment") sComputerName = ucase(oTaskSequence("OSDComputerName")) iNameLength = Len(sComputerName) If right(sComputerName,1) = "A" Then oTaskSequence("OSDComputerName") = left(sComputerName, iNameLength-1) ' The echo statement is not displayed, but rather registered in SMSTS.log wscript.echo ">>>> Set OSDComputerName from " & sComputerName & " to " & oTaskSequence("OSDComputerName") End If
To add this into your task sequence:
- Put this script into a package for your general OSD Scripts
- Ensure you have the step to capture the computer name
- Immediately after the capture windows settings, run the PC Standardization Script
- On whatever step you have that prompts for the PC Name, add a condition to not execute if variable OSDComputerName does not exist. This is so that task sequence will not be held up on the other end waiting for someone to enter a PC name for one you’ve already set.
- Finally – ensure ConfigMgr environment is configured to automatically resolve conflicting records! See this as to why https://t3chn1ck.wordpress.com/2013/02/14/error-initializing-client-registration-0x80040222/