Page 1 of 1 1
Topic Options
#185485 - 2008-02-19 08:31 PM Renaming Comptuer
JeffS Offline
Fresh Scripter

Registered: 2007-01-17
Posts: 29
Loc: Portland, OR
So, I have a group of computers that I need to rename that are located in one of our remote offices. In order to build the new computers properly I need to rename the old computers.

All of the old computers are named with a "B2-" in front of them. My idea is to replace that with "OLD-".

The only way I can figure out doing this is by using netdom. Any insight into a better way of doing this would be super duper!

 Code:
Open(1, "RenameTargets.txt", 2)

Do
	$Comp = ReadLine(1)
		
		If $Comp = ""
			Close(1)
			Exit
		EndIf
	
;**********************************
Function renameComputer()
	Select
		Case InStr($Comp, "B2-") <> 0
			$newName = Right($Comp, Len($Comp) - 3)
			$newName = UCase("Old-" + $newName)
		EndSelect
		$cmd = "netdom renamecomptuer $comp /newname:$newname /userd:username /passwordD:password /usero:administrator /passwordo:password /force /reboot:20"		
		
	EndFunction
	
	


Obviously, I am going to replace the username and password information with the correct info.

Top
#185488 - 2008-02-19 11:53 PM Re: Renaming Comptuer [Re: JeffS]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
NetDom works great. I renamed all my computers with it. Rather than pull targets from a file, I pulled the names from the domain. Part of the name stayed the same, only the prefix changed so I did string manipulation and didn't have to worry about duplicates. I used a KiXforms GUI to list them.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#185500 - 2008-02-20 09:49 AM Re: Renaming Comptuer [Re: JeffS]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Any particular reason that you don't wan't to use NETDOM?

If you have particular antipathy towards SHELLing you might find COM automation objects to perform the task, but why bother?

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 128 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.05 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org