Hello Jim,
Issue with the built-in Enable for Lync action
When is the Business Rule triggered? We suspect that if the Business Rule is triggered after creating or updating the user, this can be an issue in replication. It is possible that Adaxes performs the changes on one of your DCs, and Lync uses another DC, and the changes simply didn't manage to replicate. Try adding a timeout to your Business Rule before enabling for Lync in order to allow for AD replication. To do this:
-
Launch Adaxes Administration Console.
-
Navigate to and select the Business Rule that enables users for Lync.
-
Right-click the action that enables users for Lync and select Add New Action.
-
Select the Run a program or PowerShell script action.
-
In the Script field, type the following:
Start-Sleep -s 60
This will add a timeout of one minute to your Business Rule.
-
Enter a short description for the script and click OK.
-
With the help of the arrow buttons at the bottom, place the Run a program or PowerShell script action before the Enable for Lync action.
-
Save the Business Rule.
Also, make sure that the users, whom you enable for Lync with the Business Rule, have the Email/Telephone Number property specified.
Issue with the script
The thing is that Adaxes uses PowerShell 2.0, and Lync management cmdlets for Lync 2013 require at least PowerShell 3.0. To workaround the issue, instead of loading the Lync management PowerShell module in your script, you can create a remote PowerShell session to your Lync Server. In such a case, the version of PowerShell used by Adaxes will not matter as the cmdlet will be executed remotely on the Lync Server. The following script enables a user for Lync using a remote PowerShell session:
$lyncServer = "lyncserver.example.com" # TODO: Modify me
$registrarPool = "lyncserver.example.com" # TODO: Modify me
$sessionOptions = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck
$session = New-PSSession -ConnectionUri https://$lyncServer/ocspowershell `
-SessionOption $sessionOptions -Authentication NegotiateWithImplicitCredential
Import-PSSession -session $session
Enable-CsUser -Identity "%fullname%" -RegistrarPool "lyncserver.example.com" -SipAddress "sip:%mail%"
Remove-PSSession -Session $session
In the script, $lyncServer and $registrarPool specify the FQDNs of your Lync Server and registrar pool.
By the way, we noticed that you use the Set-CsUser cmdlet in your script. This cmdlet is used to modify the properties of the users who are already enabled for Lync. However, the built-in Enable for Lync action only enables new users for Lync. If you are trying to execute the action on a user who is already enabled for Lync, This can also be the cause for the initial issue.