Enable multiple Lync Server 2010 users using PowerShell

The Lync Server 2010 (LS) has a few new interfaces, and one of them is the Lync Server Management Shell. This is a Windows PowerShell based shell, with more than 530 Lync related commands. Each command contains “-Cs” characters, as “Communications server”, so commands are easy to list. Simply type the Get-Command *-cs*.


Get-Command *-cs*

What can we do if we need to enable a huge number of new Lync users? The answer is the automatization, let me show you my Enable-multipleLSusers script!

First of all we need a database with required inputs. I used comma separated values (CSV) file to store the script required properties of all new users. Here is my CSV file:


Identity;pool;SIPDomain
user1;lync.example.local; example.local 
user2;lync.example.local; example.local

My script reads the CSV file, and enables LS users. Here is the script:


cls
Write-Host "##########################################"
Write-Host "#                                        #"
Write-Host "#      Enable multiple LS2010 users      #"
Write-Host "#        created by: Attila Tokai        #"
Write-Host "#                                        #"
Write-Host "##########################################"
Write-Host ""

$usercsv = Import-Csv ./CSusers.csv -Delimiter ';'
ForEach ($usr in $usercsv)
{
Enable-CsUser -Identity $usr.Identity -RegistrarPool $usr.pool -SipAddressType SAMAccountName -SipDomain $usr.SIPDomain
Write-Host "	The user " $usr.Identity " enabled for LS2010 "
}
Write-Host "Enable multiple LS2010 users script finished!"
Write-Host ""

Enjoy!

Advertisements

7 thoughts on “Enable multiple Lync Server 2010 users using PowerShell”

  1. Hi,

    I like the simple script and yet so powerful. I wish you have more scripting tips for Lync automation like migrating multiple users from Legacy.

    Thanks and more power to you.
    Lito

  2. I wasn’t able to use the script. I was forced to verify that each user had an existing AD account before I could add it. Hence, I was forced to use the Control Panel GUI to add 44 accounts. It wasn’t that bad for 44, but I was wondering what I need to add to the script to verify the user name within AD?

    Thanks for your work!

    Bruce

  3. Bruce, that’s because the formatting of the page prevents showing the entire Enable-CsUser command line. Viewing the HTML source reveals the complete command:

    Enable-CsUser -Identity $usr.Identity -RegistrarPool $usr.pool -SipAddressType SAMAccountName -SipDomain $usr.SIPDomain

    Hope that helps!
    SipMart

    1. Here is your question related line:
      $usercsv = Import-Csv ./CSusers.csv -Delimiter ‘;’

      ./CSusers.csv means that the script will search the csv file at the same directory. You should overwrite the location as you wish, eg. “c:\my directory\test.scv”.

  4. Great!! I placed the csv and the script in the same directory and it worked. Thanks for the input, I appreciate it, I was wondering is we can add additional properties in the script to enable voice and set URI, how would I do that?

    Thanks!!

    1. Please check the help of the following two commands: Enable-CsUser and Set-CsUser. Type Get-Help Set-CsUser first. To enable voice for an user use the Set-CsUser -Identity "User Name" -EnterpriseVoiceEnabled $True command.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s