Often, it can be a good idea to pre-populate Communicator (MOC) in an Office Communications Server 2007 R2 before end users start to use MOC. That way they’ll not be met with an “empty” contact list when they log on to MOC. For example, you might want to populate a user’s contact list with a group containing the members of the department the user belongs to. It’s rather easy to use LCSAddContacts.WSF to accomplish this, but I wanted to automate the process based on AD security groups, not only which OU the users/contacts belong to. I am doing all these commands from C:\Program Files\Microsoft Office Communications Server 2007 R2\ResKit\WMI Samples for simplicity.
- First, I need to list all the users in the AD Group containing the contacts, using the DN (Distinguished Name) of the group:
dsget group “CN=SomeGroup,OU=SomeOuAlso,OU=SomeOU,DC=domain,DC=com” -members -expand > members.txt
- Then, I need to get the msRTCSIP-PrimaryUserAddress for these contacts:
for /F “delims=” %x in (‘type members.txt’) do (dsquery * %x –l -attr msRTCSIP -PrimaryUserAddress >> contacts.txt)
Now I have a list over the contacts that should be populated into the contact list in MOC. The delims= is necessary to read the full lines also if there are spaces. The -l attribute is needed to get only the attribute, not also the name of the attribute for each line. If contacts.txt exists, make sure it’s empty at the script does not overwrite the file, but only appends new lines. - Now I need to get the users that should get these contacts:
dsget group “CN=SomeOtherGroup,OU=SomeOtherOU,OU=SomeOU,DC=domain,DC=com” -members -expand > userlist.txt
- Then, I need to get the msRTCSIP-PrimaryUserAddress for these users:
for /F “delims=” %x in (‘type userlist.txt’) do (dsquery * %x -l -attr msRTCSIP-PrimaryUserAddress >> users.txt)
- Let the magic happen:
cscript LCSAddContacts.WSF /usersfile:users.txt /contactsfile:contacts.txt /contactsgroup:”My group”
This would be a lot easier if the users and/or the contacts could be picked from a OU (or even manually enter the sip adresseses to users.txt or contacts.txt), but in a real-world scenario you might want to create MOC Contact groups based on AD groups.
Result:
P.S. Existing groups with the same same will not be overwritten, nor will existing contacts in that group. Only new contacts will be added.


[...] Populate contacts list in Communicator with LCSAddContacts.WSF < The UC Corner Posted on June 21, 2010 by johnacook http://www.uccorner.com/126/ocs/populate-contacts-list-in-communicator-with-l… [...]
Is it possible to adjust the commands so that I can use a AD-group that has subgroups as members rather than users? These subgroups have users in them.
Hi,
I’m sure this should be possible with some tweaking of the script.
I found a new tool called OCSCM Microsoft Office Communications Server Contact Manager helps me more than I imagined to push the contact list to all or some users moreover that you can build multiple contact lists and populate/push to a different groups of users, it’s a perfect tool and easy to use more than the LCSAddContacts.WSF ,beside that OCSCM has a new version which supports (Microsoft Lync)
for more information : http://www.ocscm.com
And you can try the new version of OCSCM 2.5 Beta 1 (Lync Version)
http://www.ocscm.com/News/OCSCM-2-5-Beta-1-released-(Lync-Version).aspx