The script adds the user on which it is executed to a Lync Response Group Agent Group.
You can need to execute the script via a business rule, custom command or scheduled task only. To add it to a rule, command or task, use the Run a program or PowerShell script action.
Parameters:
- $lyncServer - Specifies the Fully Qualified Domain Name (FQDN) of your Lync Server.
- $serviceIdentity - Specifies the identity of the service where the Response Group agent group is hosted.
- $agentGroupName - Specifies the name of the Response Group Agent Group.
PowerShell
$lyncServer = "lyncserver.domain.com" # TODO: Modify me
$serviceIdentity = "service:ApplicationServer:applicationserver-001.domain.com" # TODO: Modify me
$agentGroupName = "Help Desk" # TODO: modify me
# Get the user's SIP address
$mailParams = $Context.TargetObject.GetMailParameters()
$emailAddresses = $mailParams.EmailAddresses
$sipAddresses = $emailAddresses.GetAddressesByPrefix("sip")
if ($sipAddresses.Length -eq 0)
{
$Context.LogMessage("Cannot add the user to the specified Role Group Agent Group because the user doesn't have a SIP address.", "Error")
return
}
try
{
# Connect to the Lync Server
$sessionOptions = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck
$session = New-PSSession -ConnectionUri https://$lyncServer/ocspowershell `
-SessionOption $sessionOptions -Authentication NegotiateWithImplicitCredential
Import-PSSession -session $session
# Get the Role Group Agent Group
$agentgroup = Get-CsRgsAgentGroup -Identity $serviceIdentity -Name $agentGroupName
# Add the user
$agentgroup.AgentsByUri.Add("sip:" + ($sipAddresses[0]).Address)
Set-CsRgsAgentGroup -Instance $agentgroup
}
finally
{
# Close connection to the Lync Server
Remove-PSSession -Session $session
}
Hello,
You should use the Adaxes ADSI Provider interface in your project. For details and examples of code in C#, have a look at the following SDK article: http://adaxes.com/sdk/?WritingAdsiScripts.html.