Removing existing Agent Group from the Queue.

Hi Everyone,

While working on Lync Agent groups through powershell, i was wondering how can i remove an existing Agent Group from the Queue.

Here is the code for addition:

Get the agent group identity
PS C:\> $ag_id = (Get-CsRgsAgentGroup -Name "My First Agent Group ").Identity

Add it to the queue agent group list
PS C:\>$q.AgentGroupIDList.Add($ag_id)

But how to remove already added group from the queue. The code should be like AgentGroupIDList.Remove(id), but unfortunately its not working. Thanks for any help in this regard.

August 16th, 2013 1:34pm

worked for me...

PS C:\Users\test> $ag_id=(Get-CsRgsAgentGroup -Name "Test").identity

PS C:\Users\test> $ag_id
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      055e585c-b2d1-4481-bd3f... 055e585c-b2d1-4481-bd3...


PS C:\Users\test> $q=Get-CsRgsQueue -name "Support"

PS C:\Users\test> $q.AgentGroupIDList
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      dd2c725c-1905-4d99-8949... dd2c725c-1905-4d99-894...
1-ApplicationServer-1      055e585c-b2d1-4481-bd3f... 055e585c-b2d1-4481-bd3...

PS C:\Users\test> $q.AgentGroupIDList.remove($ag_id)
True

PS C:\Users\test> $q.AgentGroupIDList
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      dd2c725c-1905-4d99-8949... dd2c725c-1905-4d99-894...

PS C:\Users\test> Set-CsRgsqueue -instance $q

  • Marked as answer by Kent-Huang Monday, August 19, 2013 7:33 AM
Free Windows Admin Tool Kit Click here and download it now
August 16th, 2013 3:06pm

worked for me...

PS C:\Users\test> $ag_id=(Get-CsRgsAgentGroup -Name "Test").identity

PS C:\Users\test> $ag_id
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      055e585c-b2d1-4481-bd3f... 055e585c-b2d1-4481-bd3...


PS C:\Users\test> $q=Get-CsRgsQueue -name "Support"

PS C:\Users\test> $q.AgentGroupIDList
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      dd2c725c-1905-4d99-8949... dd2c725c-1905-4d99-894...
1-ApplicationServer-1      055e585c-b2d1-4481-bd3f... 055e585c-b2d1-4481-bd3...

PS C:\Users\test> $q.AgentGroupIDList.remove($ag_id)
True

PS C:\Users\test> $q.AgentGroupIDList
ServiceId                  InstanceId                 NonNormalized
---------                  ----------                 -------------
1-ApplicationServer-1      dd2c725c-1905-4d99-8949... dd2c725c-1905-4d99-894...

PS C:\Users\test> Set-CsRgsqueue -instance $q

  • Marked as answer by Kent-Huang Monday, August 19, 2013 7:33 AM
August 16th, 2013 3:06pm

I did notice you have a space at the end of the name in quotes: 

PS C:\> $ag_id = (Get-CsRgsAgentGroup -Name "My First Agent Group_").Identity

Free Windows Admin Tool Kit Click here and download it now
August 16th, 2013 3:07pm

I did notice you have a space at the end of the name in quotes: 

PS C:\> $ag_id = (Get-CsRgsAgentGroup -Name "My First Agent Group_").Identity

August 16th, 2013 3:07pm

Thanks Michael, i will try again and will let you know the result.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2013 5:34pm

Hi absials,

Is there any update on the issue?

August 19th, 2013 7:33am

I am having the same problem. It seems like adding works but removing does not. I am using remote shell.

PS D:\development> $x = Get-CsRgsQueue -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "queue4"
PS D:\development> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   be320ac1-cc12-4479-b94e-eb61f4e2004f    be320ac1-cc12-4479-b94e-eb61f4e2004f
1-ApplicationServer-1                   00d13c8b-fec7-407a-aa67-4924f108c9d7    00d13c8b-fec7-407a-aa67-4924f108c9d7


PS D:\development> $agentGroup = (Get-CsRgsAgentGroup -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "aaa
aa").Identity
PS D:\development> $agentGroup

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   00d13c8b-fec7-407a-aa67-4924f108c9d7    00d13c8b-fec7-407a-aa67-4924f108c9d7


PS D:\development> $x.AgentGroupIDList.remove($agentGroup)
PS D:\development> $x


Identity          : service:ApplicationServer:lyncse6.lync6.com/d7d56944-e9db-4735-8e36-0b338ba99cc7
TimeoutAction     : Action=TransferToUri
                    Uri=sip:tuser1@lync6.com
OverflowAction    : Action=TransferToQueue
                    QueueId=7e8d7c6f-3913-4dc0-ad9b-ac72bab0d1ad
Name              : queue4
Description       : queue4
TimeoutThreshold  : 20
OverflowThreshold : 10
OverflowCandidate : NewestCall
OwnerPool         : lyncse6.lync6.com
AgentGroupIDList  : {service:ApplicationServer:lyncse6.lync6.com/be320ac1-cc12-4479-b94e-eb61f4e2004f,
                    service:ApplicationServer:lyncse6.lync6.com/00d13c8b-fec7-407a-aa67-4924f108c9d7}

PS D:\development> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   be320ac1-cc12-4479-b94e-eb61f4e2004f    be320ac1-cc12-4479-b94e-eb61f4e2004f
1-ApplicationServer-1                   00d13c8b-fec7-407a-aa67-4924f108c9d7    00d13c8b-fec7-407a-aa67-4924f108c9d7

PS D:\development>

Free Windows Admin Tool Kit Click here and download it now
August 25th, 2015 12:26pm

Yes. it worked. thanks
August 26th, 2015 7:52am

Sorry for responding too late.

Following lines worked for me:

$z = Get-CsRgsQueue -name "Test"
$Ag = (Get-CsRgsAgentGroup -identity 'Group Name').identity
$z.AgentGroupIDList.Remove($Ag)


Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 7:58am

Dear Jung,

Nothing seems wrong, please run Powershell with Admin rights and try again.

August 26th, 2015 8:16am

Thanks for the reply.

It's mystery for me too. I am using the same powershell window (remote shell) and I can add the Agent Group without problem but can't remove. One thing I notice when I add the agent group I get the 0 as response but I don't get any response when I remove the agent group from the queue.

Here is my capture from the powershell window. You can see you get the 0 back after you add the agent group but when I remove I don't get any result back.

PS D:\> $x = Get-CsRgsQueue -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "queue8"
PS D:\> $x.AgentGroupIDList
PS D:\> $agentGroup = (Get-CsRgsAgentGroup -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "rgs2").Identity
PS D:\> $agentGroup

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> $x.AgentGroupIDList.add($agentGroup)
0
PS D:\> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> Set-CsRgsQueue -Instance $x
PS D:\> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> $x = Get-CsRgsQueue -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "queue8"
PS D:\> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> $agentGroup = (Get-CsRgsAgentGroup -Identity "service:ApplicationServer:lyncse6.lync6.com" -Name "rgs2").Identity
PS D:\> $agentGroup

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> $x.AgentGroupIDList.Remove($agentGroup)
PS D:\> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\> Set-CsRgsQueue -Instance $x
PS D:\> $x.AgentGroupIDList

ServiceId                               InstanceId                              NonNormalized
---------                               ----------                              -------------
1-ApplicationServer-1                   fec707c2-19a6-45c7-8232-78fc5ff38087    fec707c2-19a6-45c7-8232-78fc5ff38087


PS D:\>








































































































Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 9:59am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics