WSH – Create Groups

Introduction – Creating Global Groups with WSH

The purpose of this script is to create a new Global group.  My example uses an OU called BulkImport, a domain called CP.com and a Global group called Managers.  Do change these variables to names in your Active Directory.

WSH Topics

 ♦

Create the Global Group

To prevent the Global group being created in the Users container we specify the OU.  This is taken care of by this line:
Set oOU=oDomain.Create("organizationalUnit", "ou=BulkImport")

Note: The syntax is OU=BulkImport (Not CN=BulkImport or CN = Users)

Note: The script does not create the OU BulkImport, either make it manually or change the script to an OU that does exist.  (However there instructions in the WSH Create User if you want to create an OU.)

°

Set the Group Object

Note: You must change dc=CP to dc=xxxxxxx where xxxxxxx is your domain name.  Also check whether or not your domain has a com extension.  If it does not, and is just a plain domain, remove the element dc=com

Instructions

  1. Copy the entire Script in the green box below.
  2. Paste it into notepad.exe.
  3. File (menu), Save as Managers.vbs.   Note: This is where people go wrong, remember the .vbs extension.
  4. Double click Managers.vbs
  5. Go to Active Directory Users and Computers OU BulkImport, Press F5.

 

‘Script to Create a Global Group in an OU called BulkImport
‘Script created by Guy Thomas
‘Feel free to adapt names
 

Set objOU = GetObject("LDAP://OU=BulkImport, dc=CP, dc=com")
Set objGroup = objOU.Create("Group", "CN=Managers")

objGroup.Put "sAMAccountName", "Managers"

objGroup.SetInfo

WScript.Echo "Congratulations, Global Group Managers created & Chr(13) Remember to Press F5"

 

Guy Recommends: Permissions Analyzer – Free Active Directory ToolFree Permissions Analyzer for Active Directory

I like thePermissions Monitor because it enables me to see quickly WHO has permissions to do WHAT.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource.  Give this permissions monitor a try – it’s free!

Download Permissions Analyser – Free Active Directory Tool

 

If you get an error message – check this page


See Also