Automate enabling and disabling Lync / Skype for Business users

When I see administrators manually enabling all of their Lync / Skype for Business users it makes me cringe. With just a few lines of PowerShell and a scheduled task you can have users enabled for Lync / Skype for Business automatically. Simply copy the script examples and modify them with your infrastructure details and make a scheduled task on your Lync / Skype For Business Server or non Lync / Skype for Business server through remoting.

The first thing to determine is who should be enabled for Lync / Skype for Business and the required settings to be given to those users. I will provide examples of different scenarios both enabling or disabling users. (All examples only search for Lync / Skype for Business users that are not currently enabled and assume that the Email Address would be the enabled SIP Address.)

Example #1: Enable all users in the company with an e-mail account matching @yourdomain.com for normal Lync use.

Example #2: Enable all users in the company within a specific Active Directory OU and an e-mail account matching @yourdomain.com for normal Lync use.

Example #3: Enable all users in the company with a specific City attribute for normal Lync use with an appropriate registrar pool.

Example #4: Enable all users in the company with a specific City attribute for normal Lync use with an appropriate registrar pool and a specific Location Policy.

Example #5: Enable all users in the company with a specific City attribute for Enterprise Voice with a specific Voice Policy, Dial Plan, Conferencing Policy, Location Policy. (Don’t forget a unique Line URI when you run the Set-CsUser command if one is required.)

Example #6: The following example highlights PowerShell Remoting to remotely execute the enabling of user accounts from a separate computer.

Example #7: The following example highlights looping through multiple cities and setting the proper pool and policies according to that city. This example uses a .CSV file that contains all the cities and their respective settings. You could accomplish the same thing through code by adding a custom object and then adding each city. Using a .CSV file is preferred as it will allow you to add/remove cities in the future without changing the script.

The following are some examples of automatically disabling users from Lync if their Active Directory account is disabled.

Example #1: Disabling Lync / Skype for Business from all users in Active Directory that are disabled.

Example #2: Remotely disabling Lync / Skype for Business from all users in Active Directory that are disabled.

Example #3: As requested, here is the solution to remotely disabling Lync / Skype for Business from all users in an Active Directory group. The key here is adjusting the LDAP Filter to only include members of a particular group.

Feel free to leave a comment with your required scenario and I will update this post with the solution.

Print Friendly, PDF & Email

12 Comments

  1. Pingback: Automate enabling and disabling Lync / Skype for Business users » PowerShell.org

    1. Steve Parankewich

      These are specifically for On Premise but portions will work on Office 365 as well. I will prepare an Office 365 Skype for Business post that shows how to automate provisioning on Office 365.

  2. Ashish

    Great article.

    “$users = Get-CsAdUser -Filter { Enabled -ne $True -and WindowsEmailAddress -like ‘*@yourdomain.com’ -and City -eq ‘YourCityName’ }”
    How do you recommend checking for multiple cities within this command? and maybe even looping to handle multiple pools?

    1. Steve Parankewich

      To check for multiple cities there are a variety of ways to handle it. I updated the blog with Example $7 that shows one technique. The other technique would be to just have a separate $users line for each City with their respective settings or a custom object. The .csv import is a preferred method.

  3. Larry

    Steve I’m looking for a script to list all Skype users that have no dial plan policy specified. Everything I try gives me more output than I want or need. Any help would be appreciated.

    1. Steve Parankewich

      It is usually best to set the Dial plan at the Site level as opposed to assigning each user one but I can help you out. As in you would like to know if a user is seen as Automatic in the Control Panel?

  4. Larry

    I setup multiple user dial plans in order to define my conferencing regions and site locations as all my users are apart of the same site with only one Front-end. I need to know how many users are inheriting the global dial plan or exactly as you stated set to automatic. Any help you can provide would be appreciated. Thanks again..

  5. Pingback: How to manage and identify disabled csaduser and csuser objects to prevent UserPoolInuse and other Topology failures | digitalbamboo's Blog

Leave a Reply

Your email address will not be published. Required fields are marked *