Enable user for Lync if not already

usslindstrom used Ask the Experts™

This should be relatively simple, but I'm drawing a blank from my searches.  If possible, can someone point me in the right direction on how to handle PS negative returns?

This is in regards to Lync, where I need to execute the following:

Enable-CSUser –identity “sAMAccountName” –RegistrarPool “SpecifiedPool” –sipAddressType EmailAddress

But, I need to add it in the "fail" portion of "Get-CSUser".  Basically, if a user isn't enabled, to go ahead and do it.

Thanks for any assistance that can be provided.  Apologies for the basic question, I've searched quite a bit for this, but keep coming back empty.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Solution Architect
Most Valuable Expert 2015
Top Expert 2015
Try the following...

You will need to run this from the Lync Powershell Management Console. While also importing the Active Directory Module.
Import-module activedirectory
$FindUsers = Get-ADUser -Filter * -Properties name, samaccountname, msRTCSIP-PrimaryUserAddress
if ($User.msRTCSIP-PrimaryUserAddress -eq $null) {
Enable-CSUser -Identity $User.samaccountname –RegistrarPool “SpecifiedPool” –sipAddressType EmailAddress
} else {
Write-Output "$User is already Lync Enabled"

Open in new window



This solution worked out perfect for us.  Thank you sir!

Apologies in delay in closing this question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial