Answered by:
Removing existing Agent Group from the Queue.

Question
-
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.
Friday, August 16, 2013 1:34 PM
Answers
-
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
Friday, August 16, 2013 3:06 PM
All replies
-
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
Friday, August 16, 2013 3:06 PM -
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
- Edited by Michael LaMontagneMVP Friday, August 16, 2013 3:07 PM typo
Friday, August 16, 2013 3:07 PM -
Thanks Michael, i will try again and will let you know the result.Saturday, August 17, 2013 5:34 PM
-
-
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.AgentGroupIDListServiceId 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> $agentGroupServiceId 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-4924f108c9d7PS D:\development>
Tuesday, August 25, 2015 4:24 PM -
Yes. it worked. thanksWednesday, August 26, 2015 11:50 AM
-
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)
Wednesday, August 26, 2015 11:55 AM -
Dear Jung,
Nothing seems wrong, please run Powershell with Admin rights and try again.
Wednesday, August 26, 2015 12:14 PM -
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:\>
Wednesday, August 26, 2015 1:57 PM