RE: Rename domain workstations based on Dell service tag?
- From: Umesh Thakur <ucthakur-NOSPAM@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Mar 2006 07:06:28 -0800
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!
- Follow-Ups:
- Prev by Date: Re: User session's lenght
- Next by Date: Re: Querying Printer Status
- Previous by thread: User session's lenght
- Next by thread: RE: Rename domain workstations based on Dell service tag?
- Index(es):
Relevant Pages
|