We help IT Professionals succeed at work.

VBScript create OU, groups, set policy settings

greghess
greghess asked
on
2,600 Views
Last Modified: 2008-05-30
Hi Experts,

I currently have a set of administrative tasks I need to automate and hope to be able to perform them in VBScript. The tasks are as follows:

1-Create an Organizational Unit
2-Apply a default Group policy
3-Set the policies folder redirect locations
4-Create a user group
5-Create users and add to group(Have this working)

I am relatively new to VBScript and ADSI and have been having trouble finding the right documentation.

First I would like to know if all these tasks(1-4) can be achieved via ADSI and VBScript?

Second, I need some example code performing these tasks?

Third, some references to documentation outlining the ADSI objects, methods and attributes for OU, Group, Policy. I found the msn doc's for ADSI User object http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/organizational_unit_user_interface_mapping.asp but it doesnt reference the handy methods like setPassword, where are these methods documented?

Many thanks,

Greg
Comment
Watch Question

Shane Russell2nd Line Desktop Support
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/persistent_object_interfaces.asp for a list of those methods and properties (like SetPassword) that you referred to.

The only thing in your question I'm not really sure about is applying Group Policies through a script (2 and 3).  I haven't had a reason to do that before, and haven't researched the options.  Everything else (creating OUs, users and groups, modifying group memberships) is fairly painless using ADSI.

Author

Commented:
Thanks, those are the doc's I have been looking for.

Can you provide sample code for creating a OU and sub Group? All the doc's/samples I have seen only show how to create a computer.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
BTW, in the "OUs" section of those AD samples, they have examples of how to add GPO Links to an OU as well.  Doesn't give you the ability to modify a GPO, but if you have one already created, you can at least link it to the new OUs as they are created.

Author

Commented:
Thanks, much appreciated.

I will post the GPO editing question separately.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.