I`m trying to get a script to work that rename the computer name during an OS Deployment. The script creates a connection to the MDT Task Sequence variables, then renames the computer account .
I want the script to rename the computer name to whatever is in the Task Sequence variable called OSDComputerName. The script executes without errors but the name doesn't change. Any help/guidance appreciated, below is the code.
Set oTSEnv = CreateObject("Microsoft.SMS.TSEnvironment")
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem")
dim objComputer 'as Win32_ComputerSystem For Each objComputer in colComputers err = objComputer.Rename(oTSenv("OSDComputerName")) Next
I want the script to rename the computer name to whatever is in the Task Sequence variable called OSDComputerName. The script executes without errors but the name doesn't change. Any help/guidance appreciated, below is the code.
Set oTSEnv = CreateObject("Microsoft.SMS.TSEnvironment")
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem")
dim objComputer 'as Win32_ComputerSystem For Each objComputer in colComputers err = objComputer.Rename(oTSenv("OSDComputerName")) Next