Can someone help with a little command line advise?
I have approx 300 PC in 50 locations that I need to rename and migrate to a domain. I’m trying to automate the process and want to use the NETDOM command to do this.
Here is the scenario:
– Most of the PC have static addresses.
– The NAME of the PC will be determined based on the IP address. ie. SnnnTmmm where nnn is the 3rd segment of the Ip and mmm is the 4th segment of the IP.
I’m using a batch file to extract the IP address to an external file or variable.
I’m struggling trying to pass these parameters to the NETDOM comand to perform the rename functions.
The error I receive is:
,he syntax of the new computer name, S173T108
is incorrect. A computer name (DNS host label) may contain letters (a-z, A-Z),
numbers (0-9), and hyphens, but no spaces or periods (.).
DNS name contains an invalid character.
—
I’m not sure if it views the variables %j and %l as invalid chars or if it’s getting a space, enter or some other invalid char in the script.
Thanks for all the help
Below is the example of the script
—
ipconfig | find “IP Address” > ip1.txt
for /f “tokens=1-2 delims=:” %i in (ip1.txt) do echo %j> ip2.txt
for /f “tokens=1-4 delims=.” %i in (ip2.txt) do netdom renamecomputer %computername% /newname:S%kT%l /UserD:adminuser /PasswordD:adminpassword /Force /REBoot:5
—