Clicky

Hi Experts,
I have created a batch file to rename computers in domain. I am going to rename approx 100 desktops. I want to create a Log file after running the batch script to verify computer names change took place or not. Below is the script

netdom renamecomputer (Current PC Name) /newname:(New Pc Name) /userd:(Domain Admin) /passwordd:(Password for domain admin) /usero:(Local admin) /passwordo:(Local admin password)

netdom renamecomputer (Current PC Name) /newname:(New Pc Name) /userd:(Domain Admin) /passwordd:(Password for domain admin) /usero:(Local admin) /passwordo:(Local admin password)

Need Log under C:/

asked 11/16/2011 12:30

maliks121's gravatar image

maliks121 ♦♦


4 Answers:
In a BAT file, do this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
@echo off
REM Build a date / time stamp in the format YYYYMMDD_hhmmss
set Stamp=%DATE:~-4%%DATE:~-10,2%%DATE:~-7,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
set LogFile=C:Log(%Stamp%).txt

(
netdom renamecomputer (Current PC Name) /newname:(New Pc Name) /userd:(Domain Admin) /passwordd:(Password for domain admin) /usero:(Local admin) /passwordo:(Local admin password)

netdom renamecomputer (Current PC Name) /newname:(New Pc Name) /userd:(Domain Admin) /passwordd:(Password for domain admin) /usero:(Local admin) /passwordo:(Local admin password)
)>"%LogFile%" 2>&1


~bp
link

answered

billprew's gravatar image

billprew

Add behind each of the commands the following line

echo %errorlevel%
if the result = 0 ==> the command was successful

You can use >>c:\filename.txt in the end of a line or command to get the output into a file
link

answered 2011-11-16 at 08:35:39

mansmanf's gravatar image

mansmanf

I did a simular excersise recently and justt use >> redirection to a server share using the Newname of the PC as the file name, so i end up with a text file for each migrated PC. Makes for easier reading


 
1:
netdom renamecomputer (Current PC Name) /newname:(New Pc Name) /userd:(Domain Admin) /passwordd:(Password for domain admin) /usero:(Local admin) /passwordo:(Local admin password)  >> \servershareNewPcName.txt
link

answered 2011-11-16 at 08:38:47

Neilsr's gravatar image

Neilsr

Just another thought too, if you had the computer names (old and new) in a TXT file, then you could do a loop in the BAT file reading each line of the TXT file and executing the ntedom command.  SO the BAT file would be just a few lines of code (leveraging the FOR /F command, happy to help with that if you want to go that way) and then you'd have the TXT file of old and new names.  Just a thought.

~bp
link

answered 2011-11-16 at 08:41:46

billprew's gravatar image

billprew

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1

Asked: 11/16/2011 12:30

Seen: 215 times

Last updated: 11/16/2011 05:21