Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Rename more than 1 OU

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Rename more than 1 OU
  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 >>
 Rename more than 1 OU - 9/22/2008 4:33:46 AM   
  nik1420

 

Posts: 58
Score: 0
Joined: 12/19/2007
Status: offline
I have been assigned the task of renaming all OUs under our Workstation OU. I know how to rename 1 OU, but I'm having trouble with more than one OU under Workstation. Not to mention there are some Workstation OUs that have up to 40 OUs.

To rename 1 OU I have:

Set objWKS = GetObject("LDAP://OU=Workstations,OU=Site,dc=fabrika,dc=com)
objWKS .Movehere _
"LDAP://OU=S/W_Dist_01,OU=Workstations,OU=Site,dc=fabrika,dc=com", "OU=SW_DIST_01"

This works.  To make the change to more than 1 OU under Workstations, that's were I need some help. Really all I need to do is remove the slash '/'. I'm thinking that I need to do an array, then remove the second character which would be the '/'

So I  have

Set objWKS = GetObject("LDAP://OU=Workstations,OU=Site,dc=fabrika,dc=com)
objwks.Filter = Array ("ou")
For each OU in objwks
strName=Replace(strName, "/", "")
Next

But the name of the OUs have not removed the '/'
 
 
Post #: 1
 
 RE: Rename more than 1 OU - 9/22/2008 5:14:22 AM   
  nik1420

 

Posts: 58
Score: 0
Joined: 12/19/2007
Status: offline
Above code wasn't working, so what I have done is to make sure that I have my syntax correct. I was incorrect in the Array, it should be

objwks.Filter = Array ("OrganizationalUnit")

then I added a Get info line to get the name. So I now have:

Set objWKS = GetObject("LDAP://OU=Workstations,OU=Site,dc=fabrika,dc=com)
objwks.Filter = Array ("OrganizationalUnit")
For each objOU in objwks
objOU.GetInfo
strName=objOU.ou
Wscript.echo strName 
strName=Replace(strName, "/", "")
Next

This code displays the OU name, but now I can't get it to rename.

(in reply to nik1420)
 
 
Post #: 2
 
 RE: Rename more than 1 OU - 9/23/2008 11:45:21 PM   
  nik1420

 

Posts: 58
Score: 0
Joined: 12/19/2007
Status: offline
Any ideas on how to get the correct name to reflect in AD?

I'm able to make the change, but can't get it to stick.

Thanks...

(in reply to nik1420)
 
 
Post #: 3
 
 
 
  

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 >> Rename more than 1 OU 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