I wrote a simple script to automate the process of user account creation in AD and to enable them for OCS with EV, which I am sharing at this blog... Before I start talking about the script further, I'd request everyone to read the following disclaimer carefully.
Disclaimer: Run the script in your environment at your own risk. This script re-writes proxyAddresses, so modify the script to have proper proxyAddresses value if you have Exchange setup. Please don’t run this script in production at any cost without testing it in your test environment, and without further modifying it to suit your requirements.
About the script: This script takes a CSV file as an input with following parameters of the user...
Display Name, SAMAccountName, UserPrincipalName, TelephoneNumber, Description, SIP Address.
The script will do followings…
· It will create the user.
· It’ll read display name from the file and write FirstName, LastName and DisplayName of the user.
· It’ll set the TelephoneNumber of the user.
· It’ll enable the user for Office Communications server
· It’ll set the SIP address (msRTCSIP-PrimaryUserAddress)
· It’ll assign the user to a pool (msRTCSIP-PrimaryHomeServer)
· It’ll enable the user for Enterprise Voice (msRTCSIP-OptionFlags)
· It’ll assign the Line URI (msRTCSIP-Line)
Steps to run the script:
Copy the following script and save it as “createNenableUsers.vbs”.
' DN of the OU where USers are supposed to be created
for i=0 to ubound(arHdr)
Header=Header & arHdr(i) & vbTab
Set objOU = GetObject("LDAP://" & lDapPath)
on error resume next
errorsOccured=0 'no errors
Set objUser = objOU.Create("User", "cn=" & arUser(0))
'assuming that fields in CSV files are: CN,sAMAccountName,UserPrincipalName,Telephone Number,Description
'Generate firstname(givenName),lastname(sn),displayname (displayname)
objUser.Put "msRTCSIP-Line","Tel:+" & arUser(3)
if err.number <> 0 then
wscript.echo "[Error] processing user: [" & arUser(0) & "] " & err.description
errorsOccured=1 'errors occured
objUser.Put "pwdLastSet", 0
objUser.Put "msRTCSIP-PrimaryHomeServer","CN=LC Services,CN=Microsoft,CN=UCOCSR2,CN=Pools,CN=RTC Service,CN=Services,CN=Configuration,DC=ucdom,DC=local"
wscript.echo "[Error] processing user password/account settings: [" & arUser(0) & "] " & err.description
if errorsOccured=0 then
wscript.echo userLine & "...Processed."
wscript.echo userLine & "...Processing..."
err.clear 'clear last error.
Step 2: Modify location of the input file…
Step 3: Modify the LDAP path, where you want to create the users..
Step 4: Modify the following line to set the default password…
Step 5: change the Pool DN
Step 6: After modifying the script as per your setup… run the following command...
Note: You should run the command from a location where this script is located.
I am sure you would need to modify the script as per your need, if you encounter any problem while doing it... Leave a comment and if time permits, I’ll respond with a reply.
Please clear my doubt.
Does this script to be run in Communication Server or we can run the script in any DC in the domain.
If i run the script in any other domain does this SIP will enable in communication server?
Thanking you in advance,
You can run this script from any machine in the domain.
I recently wrote a script more like yours, however after all settings have been committed, and I can verify that in AD, OCS does not seem to recognise that the user is indeed enabled for OCS and voice unless I open the users and click ok instead of cancel.