Tuesday, March 1, 2011

Automatically Create Active Directory Accounts for Microsoft OCS

In order to load test one of our Microsoft OCS applications, we needed to quickly create hundreds of test accounts for one of our OCS servers.  First, we created the accounts in AD, then we simply highlighted the new accounts and provisioned the accounts for our OCS server.

Here is a small vbs script to create the sample users:

Set oRoot = GetObject(LDAP://rootDSE)

Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))
Set oOU=oDomain.Create("organizationalUnit", "ou=OCS Test Users")
oOU.Put "Description", "OCS Test Users"

For i = 1 to 200

       Set oUser = oOU.Create("User", "cn=OCSTest User" & i)
       oUser.Put "sAMAccountName", "OCSTestUser" & i
       oUser.Put "Description", "OCS Test User" & i
       oUser.SetPassword "password"
       oUser.AccountDisabled = False


Wscript.Echo "Success, Check Active Directory Users and Computers - Remember F5"

Here is a screen shot of the test users:

After selecting all of the users in the explorer, we used the action to automatically provision the users for OCS - and selected the 'use SAM account' option

1 comment:

Aron_ Seo said...
This comment has been removed by a blog administrator.