Script Repository


Add user to Lync Response Group Agent Group

March 20, 2017
2022

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.
Edit Remove
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
}

Comments ( 2 )
avatar
Sivanandan
December 26, 2018

How do I convert the same into c# program? Is there any setting required for this.I have done changes but unable to retrieve the in memory object.plz help

avatar
Support
December 28, 2018

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.

Leave a comment

Related Scripts