Once, my test Hyper-V virtual machine was failing at a step that was supposed to join the machine to the domain – I used to generate the computer name by a combination which included also a serial number – and after some investigation I noticed that the Hyper-V machine was trying to join the domain with some super-long computer name string, which obviously failed as it hit some AD-computer object name limit.
So, to fix this as easiest as possible I needed to edit the computer name when the task sequence was already running by editing the TS variable that carried the generated name.
To open the command-line console, press F8 in WinPE environment, and type in :
powershell
To enable Powershell commands. Then we declare our variable for easier handling:
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
And then we can use multiple commands to view or edit the TS variables on the fly
To get a list of them all:
$TSEnv.GetVariables()
To view current value of a variable that caries the computer name:
$TSEnv.Value("OSDComputerName")
To edit the computer name variable (or any other desired variable):
$TSEnv.Value("OSDComputerName") = "NewPCName"