How to Create a Group Account with VBScript
VBScript Create Group
Groups are probably the most difficult object to control with VBScript. Fortunately, this script will create a Global Security group easily and without having to use the tricky construction involving CONST ADS_GROUP_TYPE.
Topics for Creating a Group Account with a VBScript
Whenever you configure groups, pay close attention to the Group scope and also the Group type, for example there are 3 scopes and 2 types of group. When you create a new group, one combination has to be the default; that combination is Global (scope) with Security (type). Therefore, if wish to create a different group, for example, a Universal Distribution groups then you need more scripting commands, in particular CONST ADS_GROUP_TYPE.
On this page, we get lucky and create a Global Security group. I say lucky, because we using a simple VBScript that parallels creating a group with Active Directory Users and Computers, where we accept only the default choices. However, if your mission were to create a Universal Distribution group, then your luck would run out, this script would not work.
For any type of group apart from the default of Global Security you need to master ADS CONST.... values.
Why is this example 'lucky'? Because you do not have to add ADS CONST... statements, the script just accepts the defaults which produces a Global scope and Security type of group.
Prerequisites for your Group VBScript
I recommend that you are logon as administrator, preferably at a domain controller. Alternatively, try Remote Desktop. If all else fails, you can try these script on an XP machine as a non-administrator, but why introduce extra complications? Let us start with some easy successes.
Instructions for Creating a Group Account in Active Directory
Sample Script - A Lucky Way to Create a Group
Import users from a spreadsheet. Just provide a list of the users with their fields in the top row, and save as .csv file. Then launch this FREE utility and match your fields with AD's attributes, click and import the users.
Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.
If you need more comprehensive software, download a free trial of SAM (Server & Application Monitor)
Note 1: The first 10 lines explain the purpose of the script and declare the variables. Either create an OU called Newport, or else change the strOU reference in the script.
Note 2: Keep your eye on the commas and CN= syntax. The simple, but clever command, which allows the script to work with any domain is: GetObject("LDAP://rootDSE"). Crucially, this statement binds WSH / VBScript to Active directory. The next line appends the Newport OU, as that is where our example script creates the strGroup.
Note 3: The heart of this script is: Set objGroup = objOU.Create("Group",strNewGpLong). Once the 'Group' object is born, then its sAMAccountName is added on the next line.
If you just want to create a Global Security scope and type of group, then it's your luck day, this simple method will do the job. This page just seeks to remind you or get you started with the basics of creating any object in Active Directory. However, if you want to understand and then control the type of groups that you create, then study the CONST ADS_GROUP_TYPE statements.
If you like this page then please share it with your friends
See more VBScript group examples: