Friday, June 20, 2008

CompRename - Yet another computer rename script

Use this script to rename computers from a any location in the domain. As long as domain admin credentials are supplied.
The script uses a CompRename.csv file for old,new machine names.
So comp001,nyccomp001 would change comp001 to nycomp001.
Process as many computers at a time as necessary.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
 AutoIt Version:
 Author:         Alex Belenkiy / Michael Viscovich
 Script Function:
    Rename Computers. Launch the application from anywhere on your network.
    Enter a domain\admin username and password when prompted.
    The script will cycle through the CompRename.csv file looking for OldName,NewName and will rename accordingly.
    The script relies on the netdom.exe file that is a part of the Windows Support Tools. Just extract it from there.
    Look for netdom on
#ce ----------------------------------------------------------------------------
AutoItSetOption("TrayIconHide", 1)
$username = InputBox("CompRename", "Please enter domain\admin-username:")
$password = InputBox("CompRename", "Please enter the password:","","*")
$FileName = FileOpen("CompRename.csv", 0)
if $FileName = -1 then Exit
while 1
    $FileLine = FileReadLine($FileName)
    if @error then 
    $CompName = StringSplit($FileLine, ",")
    If $CompName[0] = 2 then ShellExecuteWait(@ScriptDir & "\netdom.exe", "RenameComputer " & $CompName[1] & " /NewName:" & $CompName[2] & " /UserD:" & $username & " /PasswordD:" & $password & " /force /reboot:10", @ScriptDir)

No comments: