Computer Performance, Windows 2003, Logon Scripts

Google

WebSearch Site

 Home
Subscribe to Newsletter
WSH - Home
WSH - Simple Script
WSH - Create User
WSH - Bulk Import
WSH - Create Group
WSH - Create Contact
WSH - FSO Create File
WSH - List Members
WSH - Error Messages
VBScript Home
Logon Script Home
CSVDE & LDIFDE
 LDAP Attributes

 

 More Sections
 Guy's eBooks
 Windows 2003
 Exchange 2003 (New)
 Performance Monitor

 

 Windows 2000 AD
 Exchange 2000
 SQL Server 2000
 SharePoint Portal

 

 Litmus Tests
 Registry Hacks
 Problem Solving
 On-line advice
 Free ebooks

 

Contact Guy
About Us
Online Jobs at CP
Guy's eBooks

 

 

WSH - Bulk creation of new users

Introduction - Bulk creation of users with WSH

For a bulk import of new users, WSH (Windows Scripting Host) is an ideal method to automatically generating new user accounts. [I strongly recommend you work through WSH - Create User before tackling this page.]

WSH Topics

Create the OU

To prevent all the users being created in the default Users container, we need to create an OU.  This is taken care of by this line:
Set objOU=oDomain.Create("organizationalUnit", "ou=BulkImport")

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

˚

Set the Object

Here we tell the script where to create the users
Set objContainer = GetObject("LDAP://OU=BulkImport," & _
objRootDSE.Get("defaultNamingContext"))

Note: Check that the name of the OU (BulkImport) matches in both parts of the script.

Looping with For .... Next

This script creates 10 users, it would be so easy to create 500 by changing
For i = 1 To 10   For example,  increase 10 to 500: For  i = 1 To 500
 

In this script the usernames are Bulkuser1, Bulkuser2...  Change the name if you wish.

Instructions

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

 

 

'Script to Create multiple users in an OU called BulkImport
'Script created by Guy Thomas
'Feel free to adapt names
Dim objOU


Set oRoot = GetObject("LDAP://rootDSE")
Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objOU=oDomain.Create("organizationalUnit", "ou=BulkImport")
objOU.Put "Description", "Guy's Bulk Import OU"
objOU.SetInfo

Set objContainer = GetObject("LDAP://OU=BulkImport," & _
objRootDSE.Get("defaultNamingContext"))

For i = 1 To 10
Set objLeaf = objContainer.Create("User", "cn=BulkUser" & i)
objLeaf.Put "sAMAccountName", "BulkUser" & i
objLeaf.SetInfo
Next

WScript.Echo "Congratulations, 10 Users created Remember to Press F5"
 

 

If you get an error message - check this page

 

See Also

 

 *


Google

Webcomputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.