Script – to create users in AD and enable it for Office Communications server

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.


iput file 


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:

Step 1:

Copy the following script and save it as “createNenableUsers.vbs”.



dim Header,FileName,fs,fl,objOU

set fs=CreateObject(“Scripting.FileSystemObject”)

set fl=fs.OpenTextFile(“C:\scripts\User_Accounts-ADS-CSV.csv”)




‘ DN of the OU where USers are supposed to be created


for i=0 to ubound(arHdr)

Header=Header & arHdr(i) & vbTab


wscript.echo Header

Set objOU = GetObject(“LDAP://” & lDapPath)

on error resume next

while fl.AtEndOfStream=False

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)

arUinfo=split(arUser(0),” “)

objUser.Put “givenName”,arUinfo(0)

objUser.Put “sn”,arUinfo(1)

objUser.Put “displayName”,arUser(0)

objUser.Put “sAMAccountName”,arUser(1)

objUser.Put “UserPrincipalName”,arUser(2)

objUser.Put “telephoneNumber”,arUser(3)

objUser.Put “description”,arUser(4)

objUser.Put “msRTCSIP-PrimaryUserAddress”,arUser(5)

objUser.Put “proxyAddresses”,arUser(5)

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


end if

objUser.SetPassword “Password@123” 


objUser.put “msRTCSIP-UserEnabled”,TRUE

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”

objUser.Put “msRTCSIP-OptionFlags”,384


if err.number <> 0 then

wscript.echo “[Error] processing user password/account settings: [” & arUser(0) & “] ” & err.description

errorsOccured=1 ‘errors occured


end if

if errorsOccured=0 then

wscript.echo userLine & “…Processed.”


wscript.echo userLine & “…Processing…”

end if

err.clear ‘clear last error.



set fs=nothing



Step 2: Modify location of the input file…

set fl=fs.OpenTextFile(“C:\scripts\User_Accounts-ADS-CSV.csv”)

Step 3: Modify the LDAP path, where you want to create the users..


Step 4: Modify the following line to set the default password…

objUser.SetPassword “Password@123”

Step 5: change the Pool DN

objUser.Put “msRTCSIP-PrimaryHomeServer”,”CN=LC Services,CN=Microsoft,CN=UCOCSR2,CN=Pools,CN=RTC Service,CN=Services,CN=Configuration,DC=ucdom,DC=local”

Step 6: After modifying the script as per your setup… run the following command…

Cscript  createNenableUsers.vbs

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.



Comments (67)

  1. Premkumar Yogeswaran says:


    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,


  2. Ram Ojha says:

    You can run this script from any machine in the domain.



  3. zizebra says:

    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.

  4. says:

    As nice blog,but you could have made this blog more cool if you could configure the language changer pluigin but all the same you have done"> a good job

  5. Clash of Clans for PC says:

    I think when you are doing the things possible then its Clash of Clans for PC

  6. WeChat Messenger for PC says:

    We have working guide for downloading WeChat on Computer

  7. Clash of Clans for Computer says:

    I want to tell you that its really possible to enjoy downloading Clash of Clans on Computer

  8. WhatsApp Messenger on Computer says:

    So folks, you want to download WhatsApp Messenger on PC check this out :

  9. iOS 9 Release Date says:

    I am early waiting for the iOS 9 release date and iPhone 7 release date:

  10. Whatsapp says:

    Thanks for such a share.Well I would also like to share something with you guys

  11. iMessage says:

    Hey giys I just found out a new way through which you can get imessage on Android and you can check that out here

  12. Packers and Movers Pune says:

    Thanks for all your information, Website is very nice and informative content.
    If you are looking Best Packers and Movers so Visit at :

  13. Packers and movers Pune says:

    This article is really fantastic and thanks for sharing the valuable post.

  14. Packers says:

    This article is really fantastic and thanks for sharing the valuable post.

  15. Packers says:

    This article is really fantastic and thanks for sharing the valuable post.

  16. INSTAGRAM says:

    I really enjoyed & liked everything.
    Thanks for sharing informative post ……..


  17. Rahul Yadav says:

    This is something with which I am totally agreed for sure.. Loved the way now we can play candy crush on PC. check full guide here .. Thanks

  18. Dhruvaraj says:

    Wow. Thanks for sharing. I like this article.

  19. Saurabh says:,1632078,1632078#msg-1632078

  20. instagram says:

    Anyone is familiar with which social network sites could be the brand spanking new locations to market every little thing. Numerous Instagram admirers imply plenty of people see in addition to price your personal images. Several companies monitor this
    kind of like a new technique to market.

  21. WeChat for PC says:

    Here is a perfect guide to get WeChat messenger for PC

  22. Jassie Pinkman says:

    i think this problem is related to Windows. Try using windows 8 product key

  23. Pankaj Kumar says:

    Thanks for sharing this useful guide….

  24. Game of War for PC says:

    Thanks for this wonderful share. Now Download Game of War for PC at

  25. 3D Coloring Pages says:

    Augmented reality based 3D coloring pages let kids see and play with their colored character in 3D . 3D coloring books opens a whole new dimension in kids education. Visit now @

  26. Raj says:

    check your avaliable here

  27. aranyak says:

    awesome stuff.. keep it up..

  28. dazy saloman says:

    For trusted Packers and Movers Visit:-
    For faithful Packers and Movers Visit:-
    For verified Packers and Movers visit:-