Enable user for Lync if not already


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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
usslindstromAuthor Commented:
This solution worked out perfect for us.  Thank you sir!

Apologies in delay in closing this question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.