Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rename computer account with vbscript using task sequence variable

Status
Not open for further replies.

raiden69

MIS
Sep 7, 2015
5
ZA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top