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 ****
#AutoIt3Wrapper_outfile=CompRename.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.2.12.1
 Author:         Alex Belenkiy / Michael Viscovich
                ab@nyitsupport.com / mviscovich@earthlink.net
                06/19/2008
 
 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 download.microsoft.com
 
#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 
        FileClose($FileName)
        Exit
    EndIf
    $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)
WEnd
FileClose($FileName)

No comments: