Introducing LyncAddContacts!

Wednesday, January 5, 2011
The Office Communications Server 2007 Resource Kit Tools featured a nifty tool called LCSAddContacts.  This WSF script allows you to add contacts to LCS or OCS (but not Lync Server) using WMI.  I was hoping to see a version of this tool for Lync Server, but no such luck -- So I wrote one myself.

I'm surprised to find that there is no PowerShell cmdlet that allows you to add contact groups or contacts, and since there are no WMI classes for Lync Server anymore, I needed a way to do this -- so I wrote a tool myself.  I leverage the DBIMPEXP utility from the Lync Server DVD to import and export contacts. 

The purpose of LyncAddContacts is to add the same contact groups and contacts to multiple users programmatically.  For example, you may want to import a contact group called "Company Contacts"  that contains contacts for everyone in the company.  Here's how it works:
  1. Create a template (source) user in Lync with the contact groups and contacts that you want to export.
  2. Run the LyncAddContacts tool to export the source user's contacts
  3. Run the LyncAddContacts tool again in import mode and target the user or OU that you want to import the contacts to.
Prerequisites:
  • The tool must be run on the Lync server from which you will export/import the data.
  • You must be a member of the CSAdministrator security group to run this tool.  This group has rights to export and import contact groups and contacts to all users.
  • You must copy the DBIMPEXP.EXE tool from the \Support folder on the Lync Server 2010 installation media to the same folder where the LyncAddContacts tool will be run.
  • You must have read, write and execute rights to the folder where the LyncAddContacts tool will be run.
Note: This tool must be run under the CScript host due to the amount of output generated.  You will see a syntax pop-up window if the tool runs under WScript.

Usage:

LyncAddContacts uses the following syntax:
CScript LyncAddContacts.vbs /backup filename.xml [FE SQL server host name[\Instance]]
CScript LyncAddContacts.vbs SIPAddress [FE SQL server host name[\Instance]]
CScript LyncAddContacts.vbs /import SIPAddress | distinguished name of OU [FE SQL server host name[\Instance]]
The following examples demonstrate how to use the tool.


Use the /backup switch to backup all user data to the specified filename.  The following example backs up user data on a Lync Standard Edition server:
CScript LyncAddContacts.vbs /backup backup.xml
where backup.xml is the backup filename.

The following example performs the same backup on a Lync Enterprise Edition server:
CScript LyncAddContacts.vbs /backup backup.xml sql.domain.com
where backup.xml is the backup filename and sql.domain.com is the SQL server used by the front-end pool.
Once the backup has been performed, you can begin the export/import process.


First, you must export the source user's contact groups and contacts.  The following example exports this information from a user named "Source" on a Lync Standard Edition server:
CScript LyncAddContacts.vbs source@domain.com
where source@domain.com is the SIP address of the user you want to export.

The following example performs the same export on a Lync Enterprise Edition server:
CScript LyncAddContacts.vbs source@domain.com sql.domain.com
where source@domain.com is the SIP address of the user you want to export and sql.domain.com is the SQL server used by the front-end pool.


Second, you import the contact groups and contacts to either a single target user or a target Organizational Unit in your domain.  The following example imports the data to a user named "Target" on a Lync Standard Edition server:
CScript LyncAddContacts.vbs /import target@domain.com
where target@domain.com is the SIP address of the user you want to import the contact info to.  For Lync Server Enterprise Edition you must add the SQL server used by the front-end pool, as shown above.

The following example imports the same contact groups and contacts to all the SIP enabled users in the Users container in Active Directory:
CScript LyncAddContacts.vbs /import CN=Users,DC=domain,DC=com
Again, for Lync Server Enterprise Edition you must add the SQL server used by the front-end pool. 
In this example, were also specifying the SQL instance LyncServer:
CScript LyncAddContacts.vbs /import "OU=Lync Users,DC=domain,DC=com" sql.domain.com\LyncServer
A nice benefit of this tool is that contacts will not get a notification that so-and-so has added them to their contact list.  This is really useful in preventing unnecessary pop-ups from the Lync client.


Download LyncAddContacts.  View the source code here.


Disclaimer: I hope that the information in this blog is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by The EXPTA {blog}. Further, EXPTA shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

149 comments:

  1. Wow, what a great tool. Im going to link this in my blog to help users add groups of contacts. I could have used this a week ago- adding 20 contacts to 20 users took me all day!

    ReplyDelete
  2. Great tool! Hope there will be a powershell equivalent soon :)

    Two questions:
    1. will it modify existing groups, re-add contacts or add new?
    2. Just to make sure, this will only add the group, and not delete existing groups?

    In large deployments this may not be a practical tool, but for some general must have groups its great, thanks :)

    ReplyDelete
  3. Hi Ståle,

    The tool is additive, meaning that it only adds contacts that don't already exist in the Lync user's client. If a contact already exists in some other contact group, it will be moved to the new contact group that you are importing.

    It will NOT delete or change any existing contacts or contact groups.

    Since the tool can import to all SIP users in a target OU, I definitely think that LyncAddContacts is practical in large deployments. I wrote it with that in mind. :)

    Jeff

    ReplyDelete
  4. Yes ofcourse, but I was thinking about adding departemental groups may still be a pain in large deployments, since you need to create and maintain dummy users for each group. Or am I missing something?

    Still, its great and I will link to it from my blog :)

    ReplyDelete
  5. No, you have it right. Until Microsoft develops some PowerShell cmdlets that help us manage contacts and contact groups, this should still be useful.

    ReplyDelete
  6. Much appreciated Jeff!

    ReplyDelete
  7. This is much appreciated! This has been a show stopper for this upgrade, until now. One improvement opportunity would be to add the ability to auto-accept the contact add request for the user that is being added. This is helpful when there are alot of move/add/changes. Thanks!

    ReplyDelete
  8. Hi Drbbton,

    I'm glad this tool allows you to proceed with your Lync upgrade.

    I'm very interested in improving the tool, but I'm not quite sure what you mean by, "add the ability to auto-accept the contact add request for the user that is being added".

    The only add request that user's would see is when you populate the source account with all the contacts your wish to import. There's nothing I can do about that, but it doesn't matter whether the users ignore that request or not. Users will not see a contact request when the contacts are imported to other users. That's another big plus of this tool.

    If I misunderstood your comment, please let me know. Thanks!

    ReplyDelete
  9. Hey Jeff,

    Today we use LCSaddcontacts.wsf to add all users from a specific OU to a group with the same name in OCS. When the user was added to the destination user's contact list, there were just added without a "click here to accept this person". This wil become an issue within the organization when we are adding a new hire and it pops up on all existing employee's screens to approve this person. Does this make more sense?

    ReplyDelete
  10. Yes, and this is the same behavior with LyncAddContacts. You log in as the source user and add the new hire as a contact. The new hire will get a contact request from the source user - this is the only contact request anyone receives. Then you export and import the contacts to everyone in the company. No one will get a contact request for these imported users.

    ReplyDelete
  11. FYI - I updated the tool to include a new /BACKUP mode, which backs up all Lync user data. It is recommended that you run a backup before importing data to Lync users.

    Jeff

    ReplyDelete
  12. I can backup, and Export Fine, But when trying to import to anyone I get
    VBScript runtime error: Input past end of file

    ReplyDelete
  13. If you're getting any sort of error, please eamil me at jeff@expta.com. Please include the exact command you were running and the exact error message you received.

    I test all changes on various platforms, but your environment may be "special". I'll work up a fix ASAP. Thanks.

    ReplyDelete
  14. FYI - I released version 1.2 which fixes a problem when DBIMPEXP produces malformed XML. Sometimes it does not include a closing tag for new contacts. The tool now handles this situation.

    Please keep those cards and letters coming!

    ReplyDelete
  15. Great Tool Jeff Thanks !
    http://unifiedit.wordpress.com/2011/01/12/lyncaddcontacts-pour-lync-2010/
    David

    ReplyDelete
  16. Jeff - Great stuff. I'm glad to see this utility. Our customers are asking for it. :)

    ReplyDelete
  17. This is an AWESOME tool! Thank you so much Jeff! Is there a way to only import/export users, but not groups? We will have to push this out on a regular basis to get all of our new employees into everyone's contact list and we don't want to overwrite the user's groups they have set up.

    ReplyDelete
  18. Thanks, Lisa. As mentioned above, the tool works as a merge only. It will not delete any existing contacts or groups.

    ReplyDelete
  19. Jeff, great tool. One question in regards to updating a single user, opposite from most questions above... We put the full canonical name format, ran the script, no errors, but no update. Anything you can shed light on? Thanks again. BEN

    ReplyDelete
  20. Is there any way that the XML file holding the contacts could be generated without having to add them to a dummy account and exporting?

    ReplyDelete
  21. No, you must create a source account, add the contacts/groups, and export it to produce the correct XML file.

    ReplyDelete
  22. Is there a way to import non domain users to Lync account, it is MSN messenger contacts..., I have 200 users with more then 100 contacts in MSN messenger, the CISO want to close the MSN communicator and I am looking for way to import all these contacts to them Lync client.
    Could you please help me here?
    Thanks

    ReplyDelete
  23. Jeff - I just merged a new Lync server to our existing OCS topology. I will be slowly moving users to the Lync server. All of our users are in one OU. If I run this script against this OU, how will it affect the users that are still on OCS?
    Thanks,
    Viet

    ReplyDelete
  24. wow, it's a such great tools, Microsoft should definitely ask for your help.

    question: right now, if you try to import a list to a user and the user is already in the list, the tool will failed because the user can not be add itself to his list (normal), but how can we modify the script to skip that error and continue with the other users in the list ?

    thanks and again thanks for this tool

    ReplyDelete
  25. It already has logic that skips the user from the list of contacts.

    ReplyDelete
  26. The tool seems to export from my account (fully populated with all users) just fine. When I run the command to import (cscript lyncaddcontacts.vbs /import first.last@domain.com) and have the user restart the client, nothing changes and no contacts are added. The separate screen that pops up when running the script vanishes too fast to see if there's any useful info there.

    ReplyDelete
  27. Ok 2 things.....
    For some reason when i ran it on our OU it applied the exported users PIC to all the users that did not have a set pic???

    Second question how to i restore the backup so i can get all these pics of "Dwight form the office" off 30+ peoples profiles...

    ReplyDelete
  28. Jeff - First off, thanks for the scripts. You did a great job. I do have 1 issue which I can't figure out, maybe you can shed some light?

    This is my config and steps i took to import/export.

    I am using Standard configuration, not Ent.

    1) Created a user "lynctest@domain.com" on my DC, I gave that user full admin access (RTC).

    2) I logged into the Lync server as "Lynctest", I created a list of 6 groups, and added 36 users, assigning each user to their respected groups.

    3) I then did a cscript lyncaddcontacts.vbs lynctest@domain.com to create a backup of the user.

    4) I created a second user on the domain, adam@domain.com, added it to the Lync Control Panel, and after I made sure i was able to log in (and verified there were no contacts in there) I used the cscript lyncaddcontacts.vbs /import adam@domain.com

    Everything looked fine, no errors.

    I logged out of adam@domain.com, and then I logged back in to see that all the groups were setup correctly, however there were only 27 users total out of the 36 i actually added and exported. I tried to delete the user and re-add but for some reason I am getting a variable number added to the contact lists of the users I import to.

    Have any ideas why I don't get ALL my users imported in? Remember that these are new users.

    Thanks for your help -

    JR

    ReplyDelete
  29. Tucker,

    This must have happened because you used your personal account for the export. I strongly recommend using a new dedicated account for the export so you don't import anything but the new contacts. Restore from the backup you made before running the tool and try again.

    ReplyDelete
  30. Anonymous,

    1. The lynctest@domain.com account that you are exporting from does not need to have full admin access, just a regular user.

    2. I have not written or tested the tool for more than one group. The purpose is to create a single group for you company to export/import. It may still work, though.

    3. The backup switch backs up the entire Lync organization, not just a single user.

    4. That sounds right.

    ReplyDelete
  31. Jeff,

    Is there a way to import the buddy list from AIM to lync client. We are planning for a federation with AOL.It would be nice if we can import the buddy list to lync client, rather adding each and every user again.

    Thanks

    Coloreal

    ReplyDelete
  32. I'm not aware of any way to import AIM buddy lists to Lync. Sorry.

    ReplyDelete
  33. Thanks a lot for you tool, with your permission, I will translate it in french with some comments and post it on my blog.

    ReplyDelete
  34. Hi Jeff,

    This tool seems like it works great. I was wondering if you had any ideas a certain case I am working on.

    What I want to do in short is implement something like "AutoInitiateContacts" that will add a users manager, subordinates, and peers.

    It looks like this might be possible with your utility. But if I add a group to an OU, does this add the group to only current Lync users or current and future Lync users?

    I just want to be able to have any new user to have their team added to their contact list.

    Thanks!

    ReplyDelete
  35. Jeff:

    Thaks for the script. It's awesome.

    I'm having the same problem as someone above, however. It stops processing the import file after trying to import the user to itself. So if Brad@test.com were third in the list, the Lync account for Brad would only have the first two items.

    I saw above you said there was logic to deal with this, but I can't find it in the file anywhere.

    Any help here?

    Thanks!

    ReplyDelete
  36. To see contacts added with this tool do you need to log off from you Lync client and log back on or do they pop up immediately in your contacts list?

    Thx
    S.

    ReplyDelete
  37. You need to sign out and back into the Lync client.

    ReplyDelete
  38. Hi there!
    First of all I would like to say all the best for creating such a tool.
    One question about it. I "hate" about lync server being unable to host a user in OCS 2007 R2 and Lync at the same time. Also you can not have installed communicator 2007 r2 and lync client on the same pc. Soo when we will decide to install the new client for IM to our users we will also need to make this contact list. Is it possible to do this contact list before users are migrated?

    ReplyDelete
  39. The users must exist in Lync before you can use the tool to import contacts.

    ReplyDelete
  40. Hi Jeff,

    works great.
    Just a one question. Is there any known issue with the user-permission (Privacy Relationship)?
    If i change the view in the Communicator from "Groups" to "Status" or to "Relationshiop" the contact list is incomplete.
    The concacts added by the script are missing. If i add the user manuell he appear in this view.

    Thx
    Alex

    ReplyDelete
  41. FYI: Could be jumping the gun here... but the tool doesn't work when trying to import/export a domain admin account. Limited users still work fine for me.

    ReplyDelete
  42. To update a Windows protected account, such as Domain Admins, you must enable inheritance on that account's security settings before using the tool.

    ReplyDelete
  43. Thanks for the response, Jeff. Great tool BTW - this is going to save our organization.

    You were right about the inheritance - didn't work the first time, but it's working now. (ADUAC > Domain Admin > Properties > Security > Advanced > Inherit...

    ReplyDelete
  44. Hi Jeff- I just wanted to know if there is any way to use this tool to update MS Communicator for Mac clients. I have a few Mac users in my environment, and I'd like to take advantage of this sort of tool with them.

    Thanks,
    Parker

    ReplyDelete
  45. Typically, you run the tool directly on the Lync server. It should update all users, regardless of the client they use.

    ReplyDelete
  46. I just tried using this tool for the first time. I have a brand new account that I added a distribution list to that has 6 users in it. I see them fine in my Lync client. I am able to run the backup but when I try and run the export it tells me 'This user has no contacts to export!'. Clearly the account has contacts, any idea what I'm doing wrong? Thanks!

    ReplyDelete
  47. That's because a distribution list is not a contact. Other users have reported the same false error message, but it still seems to work. Please confirm. I'll try to get around to fixing the "error" message when I have time.

    ReplyDelete
  48. Confirming that you are correct, it is simply a false error and it does still work. Thanks so much! Now if I can figure out why forcing the address book to update doesn't actually update anything I'd be a happy man!

    ReplyDelete
  49. See Jeff Schertz's excellent blog about updating the Lync Address Book.

    http://blog.schertz.name/2010/09/updating-the-lync-2010-address-book/

    ReplyDelete
  50. That's the exact blog I'm working off of. It is excellent, however I'ved only gotten it to actually show any updates once. I've made a few more updates since, i.e. adding new Distribution Groups, but they just won't show up

    ReplyDelete
  51. Jeff I'm running into another issue with your program that I'm wondering if this has come up before. It does not seem to add the groups in alphabetical order. Meaning I currently have 5 distribution groups in my source Lync account, and regardless if I move it around to be in alphabetical order, when I export it and then import it to other users, it does not appear in alphabetical order. Is this expected? Thanks!

    ReplyDelete
  52. There is no way to control the order in which the underlying tool, DBIMPEXP, inserts the records into SQL. However, users can easily move groups around in their Lync client by dragging and dropping them.

    ReplyDelete
  53. Hi Jeff,
    I am encountering the same problem as jaustin1 The tool seems to export from the source account(fully populated with all users) just fine. When I run the command to import (cscript lyncaddcontacts.vbs /import target@domain.com) and have the user restart the client, nothing changes and no contacts are added.
    Any idea?
    thanks

    ReplyDelete
  54. Hi

    concerning the "false error" :
    This happens only when you have no normal users that are not in a distribution list. This is because the script looks for the closing "" tag when parsing the exported file which does not exist when you have no normal users in your list.

    ReplyDelete
  55. Matthias please define 'normal user.' Is this a user who is not Lync enabled?

    ReplyDelete
  56. No a normal user would be somebody you add directly to your contact list. The error mentionned occurs when your "template" user has only distributions lists in his contact list and not a single user that is not within a distribution group.
    While pasting my previous comment, the "contacts" tag was deleted because i put it inside xml brackets. The line above should actually ready "This is because the script looks for the closing 'contacts'" Tag [..]"

    ReplyDelete
  57. just out of curiosity - has somebody found a way to wipe the user's contact list and then do the import? I'm migrating a customer who has a internal re-structuring along with the migration and i need to get rid of the old groups in the contact lists

    ReplyDelete
  58. Jeff - great tool you've made.

    However, I'd like to echo the question made earlier by Brad and a couple of Anonymous users. When importing a bulk contact list with your tool, it will stop when it gets to the user in the list that the contacts are being imported into. You've made mention that there is "logic" to prevent this, but it doesn't seem to be working. I may be doing something wrong, but I believe I'm following the steps correctly.

    Any ideas for a workaround on this issue? Thank you again for providing this essential tool!

    ReplyDelete
  59. I was able to edit the LyncAddContacts.vbs script so that when importing a contact list it won't stop at the user contact that the list is being imported into. The side effect is that users will also have themselves in their list, but this is acceptable at the moment until an alternative solution presents itself. If anyone that is having the same problem is interested what I did to get this to work feel free to e-mail me at zoomlmk@gmail.com.

    ReplyDelete
  60. I have a few users that this doesnt work with.. i create a group under a barebones test user.. then run the commands for domain users.. but the new group doesnt show up in those cases.. i really cant figure out why.

    ReplyDelete
  61. Now we also have the problem, that when you update the group listings, it wipes out the end users custom ones.. anyone else having this issue?

    ReplyDelete
  62. Hi,

    I am trying to Import to all Users in a specific OU. What is the proper syntax?

    For example, the OU is: domain.local/BusinessUnit/Users

    Also, there uare sub OU's under Users. Would the script import to the sub folders as well?

    ReplyDelete
  63. We have about the same issue as markm75. Users in a groups gets merged with users in the users custom groups, even if the name of the group is completely different.
    The the custom group name changes to the imported name.

    ReplyDelete
  64. markm75, that is expected behavior. When you run the script against a user that already has a contact in another group, AddLyncContacts will move the user back into the Company group. No way around that, I'm afraid.

    Jeff

    ReplyDelete
  65. The file cannot be downloaded, any chance of getting that fixed?

    ReplyDelete
  66. Fixed the download settings. Thanks for the heads up!

    ReplyDelete
  67. I cannot get the tool to work I think it is because of how our domain environment is setup and how lync users are setup.

    I have lync SIP users setup using there email address which is for example lynctest@relit.co.uk the acutal AD user account though is lynctest.realian.rsg.local

    My lync server is lync.relian.rsg.local
    Would this setup cause the script to not work as when I run it to try and do a backup the dbimpexp starts and then errors and closes but I can't see what it says as its so fast it then says backup complete but no backup.xml file is created.

    ReplyDelete
  68. Is there a way to programmatically delete users are or groups from a large group of users? For example, If I have pushed out a group to all of my SIP users and then one person from that group leaves how do I ensure that everyone's lists are up to date?

    ReplyDelete
  69. Unfortunately, that is not possible due to limitations of DBIMPEXP.

    ReplyDelete
  70. Hello. Updating my post about reset Call forwarding settings after import: dbimpexp.exe /hrxmlfile:dbexport01.xml /sqlserver:srv140v.domain.ru /restype:user /user:test04@domain.ru
    dbimpexp.exe /import /hrxmlfile:dbexport01.xml /sqlserver:srv140v.domain.ru /restype:user /user:test04@domain.ru
    After this commands user's settings of Call forwardings are resets

    ReplyDelete
  71. I updated the script to fix the "stopping at the current user" problem reported by some folks.

    Thanks to reader David Schuck for the fix.

    ReplyDelete
  72. Greetings!

    We have used your script:
    'LyncAddContacts.vbs
    'Version 1.2, 01/09/2011
    'Jeff Guillet, jeff@expta.com
    'The EXPTA {blog} - http://www.expta.com

    And somehow the import also imports "STATUS" from exported file. How is this possible. Now all the users has instead of: "what's happening today" some STATUS WORD....

    ReplyDelete
  73. Obviously that shouldn't happen. Did you use a dedicated Lync account to run the script? Users should still be able to update their status by replacing that text or simply deleting it.

    The latest version of the script is Version 1.2, 08/29/2011. Please download the latest version, above.

    ReplyDelete
  74. Jeff: wonderful script!

    I still can't get it to work domain admins. I went to AD advanced features > security > and checked "include inheritable permissions."

    I get the error:

    LyncAddContacts.vbs(189, 5) Microsoft VBScript runtime error: Invalid procedure call or argument: 'Mid'

    ReplyDelete
  75. Hi,
    I'm upgrading some installations from 2007 R2 to Lync.. Upgraded users is not getting any contacts importet with the script. I have to re-enable them in Lync server, and then they will lose all the personal added contacts. Have anyone seen this behavior?

    ReplyDelete
  76. I am not sure that I understand the full scope of this tool. We have around 500 users that have been using the MSN messenger as their form of chat within our organization, we are now getting ready to move to Lync and need to import these contacts into the lync client. will this tool be able to do this?

    ReplyDelete
  77. Hi,

    I am having the same problem as someone reported earlier:
    Hi,

    I am trying to Import to all Users in a specific OU. What is the proper syntax?

    For example, the OU is: domain.local/BusinessUnit/Users

    Also, there uare sub OU's under Users. Would the script import to the sub folders as well?

    Does the script allowe for this to happen?

    ReplyDelete
  78. The syntax for imprting to all Lync users in your OU would be:

    CScript LyncAddContacts.vbs /import OU=Users,OU=BusinessUnit,DC=domain,DC=local

    The tool runs recursively, so it will process sub-OUs, as well.

    ReplyDelete
  79. Hi there,

    I can't thank you enough for making this tool.

    Unfortunately, I am having a problem with it. I created a template account, created all my groups and added contacts to them. Then I run the script.

    I tried importing into everyone in the OU and also into a specific user and it appears to complete successfully and tells me users need to log out and back in for changes to take effect.

    When I go to my client account and log out and back in, nothing changes. I left it for 3 hours with no change (blank contact list). So I tried deleting GAL files from the sip profile folder in the users directory and it still doesn't see any contacts or groups. Any ideas?

    Chris.

    ReplyDelete
  80. same issue here. It appears to work (all output looks thumbs up), but when told to log out and back in to reflect the changes, there's no change at all.

    ReplyDelete
  81. It seems that more people are having trouble with the new version than the old one, so I reverted back to version 1.1 for the download.

    I plan to completely rewrite this application as soon as I can get the time.

    ReplyDelete
  82. awesome, works great now, thanks!

    ReplyDelete
  83. Hi love the tool however i am having an issue importing nested OU's. For example, ou=sales,ou=engineers,ou=accounting,dc=contoso,dc=com.

    I get it cannot be found in fact it does not make it pass the second ou. Any suggestions? Thanks

    ReplyDelete
  84. I posted a question yesterday I should have included the OUs have space. So:

    ou=nj sales,ou=tech engineers,ou=accounting.

    Is the space the issue here as to why the script is not finding the OUs?

    ReplyDelete
  85. Yes, if the OU contains a space you need to wrap it in quotes: "ou=nj sales,ou=tech engineers,ou=accounting..."

    ReplyDelete
  86. Ron Barrett asks...
    I used the import tool and it worked great, I do have a funny issue. When I updated the contacts of my control account, exported and ran the /import against the user.. It does not add the new users. The 4 users in question are all doamin admins. not sure if this matters??

    ReplyDelete
  87. It shouldn't matter that they are domain admins. You can try enabling inheritance on the Advanced Security tab for those users and try again.

    ReplyDelete
  88. Seems like the issue is still there, Is there a way to reset the address book for a Lync user??? Tried reminv the user from Lync and adding again, but nothing happened.

    ReplyDelete
  89. You can disable the Lync user and re-enable them.

    ReplyDelete
  90. Jeff ... Great Work..

    i need your permission to use this share this script on my blog with your reference.

    ReplyDelete
  91. Hi Farrukh, you have my permission to share a link to this script on your blog. The EXPTA blog should be the download source in case the script is updated.

    ReplyDelete
  92. Hi, great Tool!

    Is it possible to put some more information about the contacts into Lync?
    Something about name or company.
    I have to import many Yahoo-IDs (some hundred Users with about 800 contacts each) to Lync and need a way to connect the cryptic Yahoo-IDs to a real name.

    ReplyDelete
  93. Hi guys,
    When I tried to run : CScript LyncAddContacts.vbs source@domain.com it says "can't find SIP". the command "CScript LyncAddContacts.vbs /backup backup.xml
    " is ok so it shold not be issues with ntfs permissions or AD permission. All users can log in perfectly no issues.
    any sugestions?
    thanks.

    ReplyDelete
  94. Hi Jeff,
    Thanks for the tool it worked great for importing the contacts. Here's my problem some people have left the company so I have removed them from the template account, and disabled their account from lync but they still show up in my list of lync contacts. I opened the file and back file and removed them manually but how do I import that into lync template?

    ReplyDelete
  95. Top thanks a lot great tool

    ReplyDelete
  96. Great Tool, but i made a mistake...

    How can I RESTORE the backup file so that all users have a empty list again!!!

    ReplyDelete
  97. SOOOOOO real gooood!!
    plz add "remove" feature too...
    tnx

    ReplyDelete
  98. Please,
    How can I RESTORE the backup file so that all users have a empty list again?

    ReplyDelete
  99. The way you perform a restore depends on whether you have a standard or enterprise pool.

    For standard edition use the following command:

    dbimpexp.exe /hrxmlfile:backup.xml /restype:user

    For enterprise edition use:

    dbimpexp.exe /hrxmlfile:backup.xml /sqlserver: /restype:user

    ReplyDelete
  100. Hi,Jeff. i made a mistake too , backup xml file for more times when i import to all users , but the xml file name is same- backup.xml ,so it means the backup.xml is not soure database, not empty contact list ?
    if that , can't restore users contact list, i need to set all user's contact list is empty . the main problem is here, one contact distribution group was deleted in AD , but lync client still display ,not be delete automatically . don't have a way to remove the distribution group, could you please tell me how to handle it ? thanks !

    ReplyDelete
  101. Hi, Jeff . my lync issue as following :
    i have ran LyncAddcontact.vbs to import soure to all users. also baxkup.xml has been re-writen when i do "import". maybe i can restore all user's contact list, and make it empty.
    but now this issue comes, a Contact distribution group added before need to remove . when i remove it in AD ,the contact distribution group is still display in each client . how to remove it ? use powershell ? delete it in SQL server ? i don't want each user to remove by themselves. thanks !

    ReplyDelete
  102. Anonymous: Just like any other backup, if you overwrite the backup with the same name there's no way to go back to the first backup. The tool cannot remove data from people's buddy list, it only adds to them. Users will need to manually remove the contacts or distribution groups themselves.

    ReplyDelete
  103. Hello, I am having problems with it not importing all the contacts. It pulls in all groups, but not all of the users. At the start of the list users have only 1 or 2 contacts, but the people at the end have almost all. It's like it is stopping the import at some point and skipping the rest.

    ReplyDelete
  104. It looks like the problem is that the script is stopping when it tries to add the target user to the contacts. I am working around it right now by deleting the target user from the testuser I created for exporting, exporting it then importing. I then add that user back and repeat same step for the next user. Tedious but better than adding 90 contacts to 90 users.

    ReplyDelete
  105. I'm having the issue, where its not adding the groups for a new lync user.. and also, in everyones case, it seems to delete any custom groups a user creates (removes the contacts from their custom list).

    ReplyDelete
  106. I am running this as a Domain Admin, I export someone who is a Regular User and get "TempExport.xml - File Not Found" - I have rights to this Folder, and can add files. The Backup ran without issue but the file was not saved ... so perhaps it didn't work either? Any ideas? Thanks!

    ReplyDelete
  107. I am able to export the contacts from an enabled user, however when I import, not all contacts are imported to all users. performing as domain admin on lync server standalone using the last example posted as template.. CScript LyncAddContacts.vbs /import "OU=Lync Users,DC=domain,DC=com"

    any suggestions?

    Thanks!

    ReplyDelete
  108. I found a solution to the problem that anonymous of jan 11 posted about. in the vbs script: in sub importcontacts the line if self > 0 .. change to if self = 1 that solved the problem for me. great script jeff thanks!

    ReplyDelete
  109. cscript LyncAddContacts.vbs /import "OU=myOU,dc=domain,dc=com" does not work for me. Do I need to do something prior to this?

    ReplyDelete
  110. Thanks Jeff for this wonderful tool. Releasing an IM client without any contact management is absolute failure in my opinion. You filled up the hole as best as you could and thanks again for this.

    ReplyDelete
  111. This tool is awesome, but I am having one issue - I imported to all domain users, but it didn't update everybody. I imported individually to the users that didn't get the updated contacts and noticed in the cmd window that pops up: 0 resources imported. If I delete the users from the lync server and re-add them then it works. I don't want to have to do this for everyone, but I can find no difference between the accounts that work and the accounts that don't! Disabling and re-enabling doesn't work either- they have to be completely removed. Does anyone have any ideas?? Otherwise, this is a great tool!

    ReplyDelete
  112. Hello,

    When i'm trying export contacts from SIP user e.g. gmelitauri it's saying
    "LyncAddContacts.vbs(257, 2) Active Directory: An inv
    alid directory pathname was passed"
    the command i typeing is:

    CScript LyncAddContacts.vbs gmelitauri@gac.com.g
    e [LYNC\RTCLOCAL]

    can anyone help me?

    ReplyDelete
  113. Hi,Jeff.
    tried to run this script to restore all users contacts from backup.xml . but no changes . any suggestions? thank you .


    PS C:\Lyncaddcontact> .\dbimpexp.exe /hrxmlfile:backup.xml /sqlserver:lyncdb.contoso.cn /restype:user
    SQL Schema Version: 59
    User Data Schema Version : 21
    Exporting 552 Homed Resource(s) from database...
    100% complete.
    Export completed successfully.
    PS C:\Lyncaddcontact>

    ReplyDelete
  114. My contacts on lync are not in order. We use lastname, firstname and while they all show this way which is correct they are not in order and change everytime you logout and in. It's random and it's driving everyone crazy. Every users has this problem. I tried deleting the .db file on the client and all the ADFILES on the webservice folder and the same thing happens. What's strange is that is you click on the "Status" tab to sort by status and change it back to "groups" it corrects itself and is right. Since we used Lyncaddcontact for all the client i wonder if it's a bug.. please let me know. tks

    ReplyDelete
  115. I am having this error:

    PS C:\contacts> CScript LyncAddContacts.vbs username@domain.com
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.

    Exporting contact groups and contacts from SIP user: username@domain.com

    ERROR! TempExport.xml file not found
    Check that you have permission to write to this folder
    and that the parameters you entered above are correct.

    I have rights to this Folder, and can add files. The Backup ran without issue but the file was not saved!

    Any ideas plz?

    ReplyDelete
  116. They should hire you,life saver

    ReplyDelete
  117. Thanks Jeff for creating this tool, helped us roll out a consistent grouped set of contacts perfectly for all users. I have used it subsequently to roll out new users and worked flawlessly.

    My only feature request, if possible is to be able to ensure that all users in the organisation keep the consistent contact list that I specify. For example deleting users from Lync who are no longer part of the organisation, to ensure that everyone see's the same throughout the organisation.

    Thanks once again,
    Jay

    ReplyDelete
  118. This comment has been removed by the author.

    ReplyDelete
  119. This tool is awesome. I made 6 universal distribution groups, dropped them into my lyncdummy@domain.com account, ran three batch files and ... done.
    Great stuff.
    I did notice that now my users have the groups when I add or remove someone from the group it can take a day or two for them to sync the changes (if they get them at all). Sometimes they need to logout out the client and log back in to get the new addresses but sometimes they just never get them. I found that deleting the local user sip_ directory will always get them fresh contacts. Since I was doing this for users manually, I just wrote a little app that'll do it for them. It's free and I can provide source if you'd like.
    http://www.seabyrdtech.com/bbvideo/lync-contact-syncr

    ReplyDelete
  120. Hi Jeff
    Great tool but..
    If I make an export on a user and import it to an brand new user it's works fine
    but if I try og import it on an "old" user there already have several list of contacts, nothing gets importet

    ReplyDelete
  121. Works great -- exactly what I was looking for, thanks for sharing with us!

    ReplyDelete
  122. Great work! Cant thank you enough for this awesome tool!

    ReplyDelete
  123. Thanks, Jeff. The script worked great. Some users are reporting that they are having trouble updating contact groups that they have imported using this tool. I have overcome this by using Universal Distribution Groups. When a new person is added or deleted, the change is reflected within 5 minutes.

    ReplyDelete
  124. Hi Jeff,

    I tried to download it, but link is broken now.

    Pablo

    ReplyDelete
  125. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

    ReplyDelete
  126. Hi Jeff

    I am using your script to apply groups to a few users who are working in helpdesk. Always when i import to those users, it deletes their private groups and all external contacts... I thought this script would merge contacts?

    Thanks

    ReplyDelete
  127. The user I want to copy only has groups no contacts, so the truncate doesn't seem to be working, it includes all properties, like photo settings, the bubble bar message, ect. Is there a way to change it to only copy groups? Also it only adds, is there a way to get it to remove everything except what you are importing?

    ReplyDelete
  128. Hi Jeff,
    The user I want to copy only has groups(that's all we want to replicate to other users), and it seems that the truncate from the temp export to the export is just a exact replica, nothing seems be be truncating. Also is there anyway to have it remove all groups except what you are importing for that user?

    ReplyDelete
  129. I figured it out with a users who only has groups and no contacts, just change the to . Last thing though is there a way to replace all groups with what you are importing or maybe a extra variable we can use in the cli to overwrite?

    ReplyDelete
  130. Thanks, Jeff. The script worked great.

    ReplyDelete
  131. Hi Jeff,

    I would like to try your script, is there a chance I can get a working mirror to the download link? The download link seems to be down currently, thank you.

    ReplyDelete
    Replies
    1. A router upgrade messed up port redirection. It's working now. Please try again.

      Delete
  132. Hi Jeff,

    thanks for your great script.
    I appreciate your work. So I "study" the script and wrote it in powershell, so I can use my well-loved pipeline again :)

    I hope it's ok that I quote some parts of your description?! If not, let me know it.

    You can find it here: http://codingstube.de/2012/07/powershell-add-lynccontacts-modul-v1-0/

    ReplyDelete
    Replies
    1. Nice work! I reviewed the code, but haven't tested it myself. This might work in situations where the VBScript does not.

      Delete
  133. hi,
    Just want to say thanks very much for this, its a really useful (and much needed) app. :)

    ReplyDelete
  134. Hello, recently I can not use the same tool and returns me the following error in the log: "Failed to load Msxmlsql.dll" I am using sql server 2008

    ReplyDelete
  135. Jeff has partially succeded where Microsoft has totally failed. We're lucky we have you Jeff. Thanks.

    ReplyDelete
  136. Jeff. I am experiencing a weird issue where the import fails if the SIP ID of the Target User is User.Name@domain.com. It successfully generates the Import.XML up to the point where it matches self, and all subsequent users fail. The XML is properly completed but contains partial data, and partial user import occurs. The first user in the Source XML sees nobody after the import, users halfway through the Source XML see half after the import, and the last user at the end of the Source XML sees everyone. If the user's SIP ID is UserName@domain.com (without the dot), then the import succeeds 100%.

    I would love to chat and provide sample data for consideration.

    ReplyDelete
  137. Jeff. I have begun to see this error when trying to update clients. I have been testing the Lync 2013 client and I an not sure that may be causing this error. Any Ideas???


    SQL Schema Version: 59
    User Data Schema Version : 21
    Importing Homed Resources into database...
    Error: Input file contains invalid XML.
    Details: Unexpected end of file while parsing CDATA has occurred. Line 72, position 1.
    at Microsoft.Rtc.DbImpExp.DbImport.ImportHomedResourceData(String user, Int32 dirId, ImpExpResourceType resType)
    at Microsoft.Rtc.DbImpExp.Application.Main(String[] args)
    Completed processing.

    ReplyDelete
  138. Great and easy to use . Thank you.

    ReplyDelete
  139. Hello, Jeff!
    You script works great, but we have a problem in friendly company.
    They have 1 root domain and about 7 domains also. So, the script did his work for users in e.g. contoso.com but can't locate any other domain (x.contoso.com). Try many DN's, but nothing. In better way, script doesn't see any SIP user.
    In your opinion, where is our mistake?

    ReplyDelete
  140. Dear Jeff,

    the tool works perfectly, but I have a question.

    what if I want to make all users have the same contact list, I mean is there a way to overwrite the contact list of all users and make it the same as mine??

    ReplyDelete
  141. Thanks for the wonderful tools. Is there any alternative available for Lync 2013?

    ReplyDelete
  142. Hello this tool not available for Lync 2013?

    ReplyDelete
  143. Hi thanks for the script, I have a question ...
    How will I do to copy all Contacts from one to the others in the same script ?

    ReplyDelete
  144. Does anyone have a solution like this for Lync 2013? Any information will be greatly a appreciated. Chris

    ReplyDelete
  145. Has anyone found a solution like this for Lync Server 2013 and clients running Lync 2010 or 2013?

    ReplyDelete

Thank you for your comment! It is my hope that you find the information here useful. Let others know if this post helped you out, or if you have a comment or further information.