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 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 "" -SipAddressType EmailAddress -SipDomain "" -Identity $_.SamAccountName}
RSAT with SP1


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.)

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.

Dewalt Kotze 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...

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 "" -SipAddressType EmailAddress -SipDomain "" -Identity $_.SamAccountName}

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