We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Add user to Lync Response Group Agent Group

February 18, 2021 Views: 5569

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 Dec 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 Dec 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
Loading...

Got questions?

Support Questions & Answers