Link to home
Start Free TrialLog in
Avatar of marrj
marrj

asked on

Powershell - Enable Lync 2013 Users Based on Group Membership

I am trying to write a Powershell script that enables Lync users based on their AD group membership.

http://blogs.technet.com/b/meacoex/archive/2011/04/24/powershell-script-get-group-members-and-check-for-users-that-are-not-enabled-for-lync-and-enable-these-users-using-e-mail-address.aspx 
I found this script, but it doesn't work.  I get this error.

Enable-CsUser : Cannot convert 'System.Object[]' to the type 'Microsoft.Rtc.Management.AD.UserIdParameter' required by parameter 'Identity'. Specified method is not supported.
At C:\Scripts\Lync_Test_Enable.ps1:9 char:25
+ Enable-CsUser -identity $aduser.identity -RegistrarPool lyncse.coex.com -SipAddr ...
+                         ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Enable-CsUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Rtc.Management.AD.Cmdlets.EnableOcsUserCmdlet

Any ideas on how to make this a functional script and satisfy the identity parameter?
Avatar of SubSun
SubSun
Flag of India image

You can try this simple version..replace lyncse.coex.com with your pool name and LyncGroup with your group name
Import-Module activedirectory
Import-Module lync
Get-ADGroupMember LyncGroup | Get-CsAdUser | ? {$_.enabled -ne $true} | Enable-CsUser -RegistrarPool lyncse.coex.com -SipAddressType EmailAddress

Open in new window

I really cannot take credit for this; but Lasse Nordvik Wedø ---- Lync Master:
http://tech.rundtomrundt.com/p/lync-ps-commands.html
Avatar of marrj
marrj

ASKER

Thanks, but I'm having trouble getting either one of these methods to work.

Subsun, I get an error stating that the "Get-CsAdUser" cannot accept pipelined input or the parameters dont' match the cmdlet being piped.

jakob_di, I believe the "foreach" is missing a parameter or two.  It won't run in its current state.  

Any more ideas?
Avatar of marrj

ASKER

jakob_di, I finally got your version to get past the foreach loop, but I run into problems when satisfying the Identity requirement of the CS command, as Get-ADGroupMember.Name does not return something that is usable by the Enable-CsUser command, just as I ran into with my own version.
Avatar of marrj

ASKER

THis is what pointed me to the use of the "Get-CsAdUser" cmdlet, but I get a similar error about mismatched properties when using it as well.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marrj

ASKER

Awesome!  That worked.  

What does the %{} do exactly?
% is an alias for ForEach-Object which i used to loop through the results of command Get-ADGroupMember

Refer following article to know more details about ForEach-Object
http://ss64.com/ps/foreach-object.html