Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VB Script to change computer names and AD computer account remotely

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,31378
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VB Script to change computer names and AD computer account remotely
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 VB Script to change computer names and AD computer acco... - 2/21/2006 8:09:16 AM   
  abulsara

 

Posts: 1
Score: 0
Joined: 2/21/2006
Status: offline
Hello to all.  Let me first start by saying that by no means am I a script writer.  What I am looking from someone is a script where I can change the computer name and the computer account for Active Directory network.  Maybe, pull the computer names that needs to be changed from an excel file.  We have about 200 workstations and we would like to make all the computer names comply with the company standard.  I don't want to manually connect to the workstation through VNC, log in, change the computer name and then reboot.  Once that is done, then go to ADUC and change the computer account name as well. 


Hope anyone can help.
 
 
Post #: 1
 
 RE: VB Script to change computer names and AD computer ... - 2/21/2006 8:30:18 AM   
  edavis6678

 

Posts: 122
Score: 0
Joined: 1/12/2006
Status: offline
I've looked into this already.

there is a WMI method that you can use to change a computer name remotely, but it does NOT work when the computer is a member of a domain.

I basically didn't do anymore research into the mattter since I couldn't do it remotely.




(in reply to abulsara)
 
 
Post #: 2
 
 RE: VB Script to change computer names and AD computer ... - 2/21/2006 10:45:34 PM   
  Reodor

 

Posts: 2
Score: 0
Joined: 2/21/2006
Status: offline
Hi

I'm not aware of any vbscript-commands which can do what you ask for. One of the tools you can use instead is NETDOM (latest version comes with Windows Server 2003 Resource Kit).

If you use "NETDOM RENAMECOMPUTER ...." you will rename both the computer and the computeraccount in AD.

Good luck

(in reply to abulsara)
 
 
Post #: 3
 
 RE: VB Script to change computer names and AD computer ... - 2/21/2006 11:30:17 PM   
  crazymatt

 

Posts: 296
Score: 0
Joined: 3/4/2005
From:
Status: offline
Here is a script i used for doing what you want. The script do use the netdom.exe so you will need that.
It was part of a bigger script so i have removed some stuff so the following script is untested. hopefully i havnt removed anything important. :D
You will have to edit <domain> in the RenameComp function to whatever your domain is called. Just search for <domain> and put your own there (without the <>).


      

Excuse the formating, my original formating seems to be lost when i pasted it in here.
Hope it helps!

/CM

< Message edited by crazymatt -- 2/21/2006 11:32:15 PM >


_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to abulsara)
 
 
Post #: 4
 
 RE: VB Script to change computer names and AD computer ... - 2/22/2006 1:58:08 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
Yeah I don't know what it is about this board, but formatting just doesn't seem to work for some people and works just fine for others. Here is crazymatt's code with formatting (I am one of the lucky ones):

      

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to crazymatt)
 
 
Post #: 5
 
 RE: VB Script to change computer names and AD computer ... - 2/22/2006 2:19:50 AM   
  crazymatt

 

Posts: 296
Score: 0
Joined: 3/4/2005
From:
Status: offline
Tnx for the help eb

/CM

_____________________________

-There is only 10 sorts of people, those who understand binary and those who dont.

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: VB Script to change computer names and AD computer ... - 12/29/2006 7:19:15 AM   
  alienprotein

 

Posts: 45
Score: 0
Joined: 2/23/2005
From: USA
Status: offline
I have been tooling around with this script and don't get why I get errors on each line that contains: "<span class="high">computer</span>" Each time I run the script there is an error telling me Error: expected  ")" Code: 800A03EE

I must not be understanding the instructions very well. Can someone enlighten me? Please!

(in reply to crazymatt)
 
 
Post #: 7
 
 RE: VB Script to change computer names and AD computer ... - 12/30/2006 3:21:21 AM   
  dm_4ever


Posts: 2672
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Remove those tags span tags. They shouldn't be there. 

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to alienprotein)
 
 
Post #: 8
 
 RE: VB Script to change computer names and AD computer ... - 1/3/2007 3:48:39 AM   
  alienprotein

 

Posts: 45
Score: 0
Joined: 2/23/2005
From: USA
Status: offline
Well this script is now officially tested and verified non functional.
 
1. Script creates both failure.txt and success.txt files at the same time. <-can't tell if it is supposed to create both, but if so, this makes no sense to me.
2. Does not create changename.xls - Not even sure if it is supposed to create the excel file. <-have modified my test script to create the spreadsheet
3. Unsure what objTextFile is equal too, so that errors when debugging.
4. At no time does it prompt for a new computer name, nor does it use a name that I manually placed in col 2 of changename.xls. In fact the spreadsheet is not being written to at all after it is created. I can correct this but always have problems with Dictionary objects.
 
crazymatt,
could you post all of the code this was taken from, so I can figure out where I am going wrong when I attempt to fix this?
 
It is hard to believe renaming a domain PC could be so darn hard to do with a script.
 

(in reply to crazymatt)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VB Script to change computer names and AD computer account remotely Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts