gdalinis
(Fresh Scripter)
2002-02-15 04:35 PM
Rename Workstation

Hi All,

I was working on a script to rename the workstation name. I have a ghost image (trying to get rid of it) and autologon when first boots and runs the following script:

    ;writevalue("HKEY_CURRENT_USER\Volatile Environment","LOGONSERVER","\\$compname","REG_SZ")
    ;writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultDomainName","$compname","REG_SZ")
    ;writevalue("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName","ComputerName","$compname","REG_SZ")
    ;writevalue("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","$compname","REG_SZ")
    ;writevalue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","Hostname","$compname","REG_SZ")
    ;addkey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ncpa\CurrentVersion\ConfigChanged")

The beginning of each line begins with a ; so if it wraps, sorry. I don't know how to make it smaller. Anyways, in the beginning of the script, it prompts for $compname and after the input is recieved, it runs through and does the renames. After its done, it reboots and I have another script run that joins it to the domain. After its done it reboots again and gives the login screen. Well, when I do this and try to login to the domain, I get a trust error. If I run script, reboot, and manually join to the domain I get the same problem so its somewhere in renaming the workstation. I looked at previous postings and couldn't find anything that wasn't free. Can anybody help? I hope I explained as detailed as possible. Thanks in Advanced.



**DONOTDELETE**
(Lurker)
2002-02-16 12:11 AM
Re: Rename Workstation

have a look here :
http://www.swynk.com/winscript/SCRIPT_RenameWorkstationVBS.asp

"netdom.exe" from w2k resource kit is really powerful. It can perform tasks like join/remove from domain, or query active directory for servers and workstations on an eye blink. The above script is based on that.
ps1.You have change ths sid or you have run the sysprep, haven't you ?
ps2. Are you from Greece ?

[ 16 February 2002: Message edited by: novastar ]

Les
(KiX Master)
2002-02-16 04:13 PM
Re: Rename Workstation

I don't understand why so many people try to hack this into place when M$ provides the SysPrep and Setupcl tools. All you need is to put the info in the SysPrep.inf file and you're good to go.
If you Ghost (TM) images, it is imperative that each PC have a unique SID and while different ghosting software have their own SID changer, M$ will only support SysPrepped builds.
To learn more about SysPrep, search TechNet for "Automating Windows 2000 Deployments with Sysprep".


LonkeroAdministrator
(KiX Master Guru)
2004-02-27 04:16 PM
Re: Rename Workstation

doh, yes, sysprep may support sid changes but is not so helpfull on the compname part

Sealeopard
(KiX Master)
2004-02-27 04:25 PM
Re: Rename Workstation

A) You're resurrecting a two-year old thread!

B) SYSPREP installs have the ability to rename computers.


Co
(MM club member)
2004-02-27 11:15 PM
Re: Rename Workstation

In the past I have used GhostWalker for such things...

pvds
(Hey THIS is FUN)
2004-02-28 05:17 PM
Re: Rename Workstation

Maby you can take a look here? NewSID


LonkeroAdministrator
(KiX Master Guru)
2004-02-28 09:50 PM
Re: Rename Workstation

jens:
a) did it on purpose
b) like said, sysprep is not that flexible in this without creating your own custom script and then it's no more sysprep... and in first place it's basically not sysprep but the unattended install system beneath


Walshie
(Lurker)
2004-03-03 07:17 AM
Re: Rename Workstation

I have written an application in C# to rename a computer name, i do the same thing as you, have autologon, but after ghosting i use ghstwalk from symantec, i script that into the ghost process, after that finished machine restarts and computer name gets changed after autologon finished

send me an email to christopher.walsh@qr.com.au and i will send you the code example



LonkeroAdministrator
(KiX Master Guru)
2004-03-03 08:14 AM
Re: Rename Workstation

well, I do the rename in minisetup.
fire up kixforms and ask for the compname along with the additional soft to install.
once continue pressed, check the domain for same compname, if there, give an error and ask for another name.


otf
(Getting the hang of it)
2004-03-03 11:01 AM
Re: Rename Workstation

thanks for that link,
we use ghosting all the time!


maiike
(Fresh Scripter)
2004-03-08 05:37 PM
Re: Rename Workstation

Here were my thoughts :

I wanted to rename the computers according to a file containing MAC Adresses for instance, so that it'd be completely automatic.

Explanation :
The computer would receive the ghost image, execute the minisetup, autologon, change its name reading in a file where its name corresponds to its MAC address, join the domain and tadaaa !
That's for complete disaster recovery with no user input at all...

Tell me what you think.

I love this BBS


Sealeopard
(KiX Master)
2004-03-08 05:44 PM
Re: Rename Workstation

Yes, doable via the NETSET.EXE utility. See http://support.microsoft.com/default.aspx?scid=kb;[LN];268781

maiike
(Fresh Scripter)
2004-03-08 05:50 PM
Re: Rename Workstation

wow that's what I love about this, the super fast response...Thanks


LonkeroAdministrator
(KiX Master Guru)
2004-03-09 05:34 AM
Re: Rename Workstation

hmm...
not fully done with my sysprep package but it does the rename in minisetup thus removing 1 reboot need.
on the first boot, autologon and install optional software unattended and join to domain.
during next reboot, computer is fully corp-ed.


Sealeopard
(KiX Master)
2004-03-09 01:57 PM
Re: Rename Workstation

I'm doing the renaming after SYSPREP as the user has the ability to enter a computername through KiXforms that runs after the mini-setup.

LonkeroAdministrator
(KiX Master Guru)
2004-03-10 10:00 PM
Re: Rename Workstation

ja, I do the same, with kixforms, DURING the mini-setup.
like said, I save 1 boot.


Radimus
(KiX Supporter)
2004-03-10 10:19 PM
Re: Rename Workstation

have you seen my script in (last post in thread):
http://www.kixforms.com/forum/viewtopic.php?t=143&sid=3d0c7c40615c5841385f349bd0965854



AdilB
(Lurker)
2004-06-28 09:53 AM
Re: Rename Workstation

Here were my thoughts :

I wanted to rename the computers according to a file containing MAC Adresses for instance, so that it'd be completely automatic.

Explanation :
The computer would receive the ghost image, execute the minisetup, autologon, change its name reading in a file where its name corresponds to its MAC address, join the domain and tadaaa !
That's for complete disaster recovery with no user input at all...

Tell me what you think.

I love this BBS


Hi

I wanted to ask you if you mayb already found an answer to your question,..
because im sitting here with this same question..
its now 2 weeks ive been looking and working on it, but it seems that something goes wrong...
if you found it mayb you can help me..
hope to hear soon from you

With kind regards

Adil B


GyroTwister
(Fresh Scripter)
2004-07-02 02:37 PM
Re: Rename Workstation

As far as i know there are two places in the registry to rename a workstation. I change them through the following scriptlines:

$rc = WriteValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","$Asset","REG_SZ")
$rc = WriteValue ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","$Asset","REG_SZ")

$Asset is a variable which I read from the DMI code of the machine.

Hereafter I reboot and call a second script which makes the machine a part of the domain, I'm using NETDOM.EXE to do this. The main lines are these:

Netdom.exe join
%COMPUTERNAME% /domain:<domainname> /userd:administrator /passwordd:<password>




Sealeopard
(KiX Master)
2004-07-03 05:19 AM
Re: Rename Workstation

This method would leave the old computername still attached to the domain, which is not desireable.

NTDOCAdministrator
(KiX Master)
2004-07-03 11:35 AM
Re: Rename Workstation

As long as there XP Workstations NETDOM can do the rename and join/move into the Domain.

Microsoft Knowledge Base Article - 298593
HOW TO: Use the Netdom.exe Utility to Rename a Computer in Windows XP
http://support.microsoft.com/?id=298593


Les
(KiX Master)
2004-07-03 03:07 PM
Re: Rename Workstation

NETDOM5 can rename Win2K as well.

NTDOCAdministrator
(KiX Master)
2004-07-04 08:14 AM
Re: Rename Workstation

Thanks Les,

Hadn't tried it and documentation only mentioned XP not 2000.


jechilt
(Starting to like KiXtart)
2005-02-09 05:57 PM
Re: Rename Workstation

Quote:

NETDOM5 can rename Win2K as well.




never heard of netdom5. where can we get this file?
we need to rename our win2k computers.


Les
(KiX Master)
2005-02-09 06:10 PM
Re: Rename Workstation

From Microsoft... it is listed as an AD Recovery Tool.

Les
(KiX Master)
2005-02-09 06:17 PM
Re: Rename Workstation

Best Practices: Active Directory Forest Recovery
http://www.microsoft.com/windows2000/downloads/tools/default.asp


NTDOCAdministrator
(KiX Master)
2005-02-09 06:24 PM
Re: Rename Workstation

Here are some updated links to help you locate the tool. Best bet would be either the Windows XP SP2 Tools update or the Server 2003 version. The link listed by Les does have the NETDOM.EXE file inside along with a whitepaper, but is an older version then the 2003 and XP SP2 version updates.

Description of Netdom.exe Syntax and Versions
http://support.microsoft.com/default.aspx?scid=kb;en-us;329721

Windows XP Service Pack 2 Support Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38&displaylang=en&Hash=W6YFBY9

The following Support Tools have been updated in Service Pack 2:

bitsadmin.exe
extract.exe
httpcfg.exe
iadstools.dll
ipseccmd.exe
netdom.exe
replmon.exe

How To Use the Netdom.exe Utility to Rename a Computer in Windows Server 2003
http://support.microsoft.com/default.aspx?scid=kb;en-us;325354

This article describes how to use the Netdom.exe utility (included in Windows Server 2003 Support Tools) to rename a computer that is a member of a Microsoft Windows 2000 or Windows Server 2003 domain. This procedure can be performed either locally or remotely on the computer that is being renamed. Also, the procedure does not require that you to reset or manually re-create the computer account in the domain.
The Netdom.exe utility can rename a computer that is a member of a Windows Server 2003 domain. However, to rename the computer, you must specify the user accounts that have local administrative permissions and the object of the computer account in Active Directory.

How To Use the Netdom.exe Utility to Rename a Computer in Windows XP
http://support.microsoft.com/kb/298593/EN-US/

Windows Server 2003 Administration Tools Pack
The Windows Server 2003 Administration Tools Pack (Adminpak.msi) provides server management tools that allow administrators to remotely manage Windows 2000 Servers and Windows Server 2003 family servers. This is the final version (build 3790) of the Adminpak.msi file.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c16ae515-c8f4-47ef-a1e4-a8dcbacff8e3&DisplayLang=en

Windows Server 2003 Resource Kit Tools
The Windows Server 2003 Resource Kit Tools are a set of software tools for administrators, developers, and power users to manage Active Directory, Group Policy, TCP/IP Networks, Registry, Security, Scalability and many other areas of the Windows Server 2003 operating system.
http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en



Les
(KiX Master)
2005-02-09 06:32 PM
Re: Rename Workstation

The question was:
Quote:

never heard of netdom5. where can we get this file?




My link is to version 5.2.3687.0 otherwise known as NETDOM5. I have used this version to rename hundreds of W2K machines using a KiXforms script that I posted on this board.


Radimus
(KiX Supporter)
2005-02-09 10:11 PM
Re: Rename Workstation

This is a piece of aq kixform I wrote to join, rename, and move XP machines in AD... You will need to dig into it to get at the few lines of code that do each function.

Code:
 


$newName = $ComputerBox.text
$domain = $DomainBox.text
$password = $PasswordBox.text
$user = $AdminBox.text
$OU = $OUCombo.text
$JOINType = 1 + 2 + 32

$objNetwork = CreateObject("WScript.Network")
if not @error
$strComputer = $objNetwork.ComputerName
$objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"+$strComputer+"\root\cimv2:Win32_ComputerSystem.Name='"+$strComputer+"'")
$ReturnValue = $objComputer.JoinDomainOrWorkGroup($Domain, $password, $Domain+"\"+$user, $OU, $JOINtype)
If $ReturnValue
Status("Failed joining "+@wksta+" to "+$domain)
Status($ReturnValue)
return
EndIf
sleep 20

Status("Renaming")
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objComputer in $colComputers
$err = $objComputer.Rename($NewName, $password, $Domain + "\" + $user)
If $err
Status("Failed Renaming "+@wksta+" to "+$NewName)
Status($err)
endif
Next

For Each $name In split($AccountsBox.text,',')
$name=trim($name)
Status("Adding User "+$name)
if not $name="Domain Admins"
$objGroup = GetObject('WinNT://' + @wksta + '/' + 'Administrators')
$objGroup.Add ('WinNT://'+ $domain + '/' + $name)
if @error
Status(@serror +' error adding '+$name)
EndIF
endif
Next
Status("Complete - Restart PC")
endif




jechilt
(Starting to like KiXtart)
2005-02-11 12:59 PM
Re: Rename Workstation

Quote:

From Microsoft... it is listed as an AD Recovery Tool.




thanks...got it.


ClientMaster
(Fresh Scripter)
2005-02-22 01:09 AM
Re: Rename Workstation

Just a note:

I use a free app called NEWSID to rename the workstation and change the SID.
I have scripted to automatically rename PC to serial number, change SID, reboot, add to domain, reboot and so on.
I have had no problems with NEWSID...also very easy to use.


Sealeopard
(KiX Master)
2005-02-22 03:01 AM
Re: Rename Workstation

Just renaming a workstation does not necessitate a SID change. SIDs only need to be changed if the operating system is being cloned. And even then, the use of e.g. SYSPREP will take care of the SID-issue. Only clonign an OS after the GUI-based setup will require a SID change.