RE: Rename domain workstations based on Dell service tag?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



well, this is sample (craft it to suit your need :)
note that this script displays constructed NETDOM command to execute,
and executes it further. /force switch of netdom will suppress any
messages displayed by netdom. if you don't want to use /force switch,
remove it. you will also need to change 0 to 1 in "wshShell.run
strCommand,0,True" line.
because, if netdom asks for any input, command window should be visible.

'-------------------
dim fs, strCompFile

strCompFile="d:\comps.txt" 'file containing list of computers to rename.
set fs=CreateObject("Scripting.FileSystemObject")
if NOT fs.fileExists(strCompFile) then
wscript.echo "Text file containing computer names to rename not found."
wscript.quit
end if

'write the code to read values of following
'better you read values for these variables using inputBox function, so that
script does not contain hardcoded passwords!
strUser = inputbox("Enter name of user with domain admin rights in
domain\user format:")
'do the same for variables below...
strUserPass = "abcdef123"
localAdmin = "local_admin acct"
localAdminPass ="pass_4_local_admin"

set fl=fs.openTextFile(strCompFile)
while not fl.atEndOfStream
strCompName=fl.readLine
strNewName = "XYZ1" & strCompName
strCommand = "%comspec% /c netdom renamecomputer " & strCompName & "
/newname:" & strNewName _
& " /userD:" & strUser & " /passwordd:" & strUserPass & " /usero:" &
localAdmin & " /passwordo:" & localAdminPass & " /reboot:" & rebootTime & "
/force"
wscript.echo strCommand
wshShell.run strCommand,0,True '0 means hide the command window, True
means-halt execution of script until this command is completed execution.


wend
fl.close

-----
Umesh

"Old programmers never die. They just terminate and stay resident."



"GM" wrote:

You make that sound so easy! :) I'm a little unclear on how to pass the
serialnumber from w32_systemenclosure to the netdom utility. Most of my
scripting in the past has been using the command line utilities, and not WSH.
Using the script-o-matic tool from MS, I was able to figure out how to get
the serialnumber from WMI, and create a txt file that contains only the
serial number. I suppose i could read the text file to get the info for
netdom, but I'm sure there is an easier/better way.

Any suggestions? Thanks!

"Umesh Thakur" wrote:

I would say, use the netdom util in your script to rename computers...
How To Use the Netdom.exe Utility to Rename a Computer in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;298593&sd=tech

get the Dell service tag (serial number) using WMI
construct the computer name using it.
specify it as a parameter to netdom,
you may also want to read admin user n passwd when script runs, so that you
dont need to hardcode it in script.
and, if your computers in single ou, you may want to use the script:
http://www.microsoft.com/technet/scriptcenter/csc/scripts/ad/computers/cscad006.mspx

to enumerate through the computers list, and pass their names to netdom, to
rename...

-----
Umesh

"Old programmers never die. They just terminate and stay resident."



"GM" wrote:

I have about 200 XP Pro Dell workstations running on a 2003 AD. I would like
to script a domain-wide workstation rename, based in the Dell service tag. I
want to pull the SerialNumber from WMI (unless there's a better way), prepend
4 letters to the SerialNumber, and rename the computer on the domain based on
this info. i.e. XYZ1-95RDW71.mydomain.local

I've done quite a bit of reading on this, but haven't found much on this
specific request. Any suggestions or info will be much appreciated.

Thanks!

.



Relevant Pages

  • Re: MATLAB Code for a stop process button which ex
    ... especially in the while loop(for each script command starting in the ... % varargin command line arguments to stop_button ... % line_num is the order of execution. ... msgno = msgno+1; ...
    (comp.soft-sys.matlab)
  • Re: Runtime Syntax Checker
    ... If any Tcl command sets a return code other than zero, ... script to abort, but any following scripts will execute. ... In C, you can ignore errors, execution ... The caller must then handle the exception. ...
    (comp.lang.tcl)
  • Re: parsing script arguments in QuestaSim/ModelSim
    ... run a TCL script which invokes another script using the DO command. ... This will certainly tell you if you have a Tcl execution ...
    (comp.arch.fpga)
  • New command execution vulnerability in myPhpAdmin
    ... New command execution vulnerability in myPhpAdmin ... this method assumes that the 'test' table in the mySQL database has ... These evalfunctions are called if the rest of the code in the script executed ...
    (Bugtraq)
  • Re: Embedding a Tclinterp : some pointers requested !
    ... > In our app, various script files using Tcl syntax will ... > - let the user cancel the execution, ... > - when the current command is complete, ... > - it does not allow to stop the interpretation in case of an infinite ...
    (comp.lang.tcl)