Wednesday, June 1, 2011

Lync 2010 - Enabling All Users in OU

Here is a quick script to enable all users in Lync 2010. To run this all on one computer you need to have Lync Tools and RSAT on it. This script is enabling all users using their EmailAddress as their SIP address. Change out domain with your domain name and Myusers with your OU or Container. The LyncPool1.domain.com is  your Lync Pool FQDN.
Import-Module activedirectory
Import-Module Lync
Get-ADUser -Filter * -SearchBase "OU=MyUsers,dc=domain,dc=com" | foreach {Enable-CsUser -RegistrarPool "LyncPool1.domain.com" -SipAddressType EmailAddress -SipDomain "domain.com" -Identity $_.SamAccountName}
References:
RSAT with SP1
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d&displaylang=en

5 comments:

Anonymous said...

Trying to do this and get the following after modifying it for my domain:

cmdlet Get-ADUser at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Filter:

Any ideas?

lupid said...

I get the same error! :(

Patrick Nielsen said...

Sorry for the delay guys. After taking a look at it I forgot to copy the filter property: -Filter *.
I use * for all users but if you needed you can exclude users using that filter property.

I updated the post to reflect this and good luck on your Lync deployments.

Unknown said...

Hi Patrick

Thanks for your script it's helping a lot, one question, if I want an export of notifications which could not be enabled what would I need to add ?

Patrick Nielsen said...

Dewalt,
I would use a output variable to store the results. If enable-csuser throws exceptions instead of powershell then you will have to use Try Catch or what I could only think would be easier compare your AD User base to your CSUser enabled users.

Taking Results
$output = Get-ADUser -Filter * -SearchBase "OU=MyUsers,dc=domain,dc=com" | foreach {Enable-CsUser -RegistrarPool "LyncPool1.domain.com" -SipAddressType EmailAddress -SipDomain "domain.com" -Identity $_.SamAccountName}

Or
Import-Module activedirectoy
Import-Module lync
$adusers = Get-ADUser -Filter * -SearchBase "OU=MyUsers,dc=domain,dc=com"
$csusers = Get-CsUser
$diffusers = Compare-Object -ReferenceObject $adusers -DifferenceObject $csusers -Property SamAccountName