locked
Add/remove Skype user to multiple or all Response groups from powershell RRS feed

  • Question

  • Hi, I have looked up for away to add/remove a user or multiple users to many or all the response groups that I have on my skype server but couldn't find anything except one powershell which is not working on this page

    https://sysnetdevops.com/2017/03/23/bulk-remove-users-from-response-groups-with-powershell/

    Anyone possibly know how to do so via powershell?

    Thanks a lot


    Mohammed JH

    Monday, December 11, 2017 6:04 PM

All replies

  • Hi moh10ly,

    You could refer to the following link about add a new agent to an agent group:

    https://blogs.technet.microsoft.com/nexthop/2011/07/13/lync-server-admin-guide-managing-response-groups/

    if you want to remove users from multiple response groups using user variable

    $cred = Get-Credential “Domain/User”
    
    $session = New-PSSession -ConnectionURI “https://Lync Server FQDN/OcsPowershell” -Credential $cred
    
    Import-PsSession $session
    
    # Set $total to 0
    
    $total = 0
    
    # Set New User Variable
    
    $newuser = "sip:lync.test1@test.com"
    
    $newuser
    
    # Identify Response Groups containing the user specified in $newuser
    
    $FindGroups = Get-CsRgsAgentGroup | Where-Object {$_.AgentsByUri -eq $newuser}
    
    $Findgroups
    
    # Count Number Of Response Groups Agent Is A Member Of
    
    $total = $FindGroups.count
    
    # Start Loop
    
    Do {
    
    $current = $total-1
    
    $currentgroup = $FindGroups[$current]
    
    $CurrentGroup.AgentsByUri.Remove("$newuser")
    
    Set-CsRgsAgentGroup -Instance $Currentgroup
    
    $total = $total-1
    
    }
    
    While ($total -gt 0)
    


    Regards,

    Leon Lu


    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Tuesday, December 12, 2017 5:38 AM
  • Are there any update for this issue, if the reply is helpful to you, please try to mark it as an answer, it will help others who has similar issue.

    Regards,

    Leon Lu


    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, December 13, 2017 9:07 AM
  • Hi Leon, 

    No the cmdlet didn't work as I am getting this error

    Cannot index into a null array.
    At line:27 char:1
    + $currentgroup = $FindGroups[$current]
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray
     
    You cannot call a method on a null-valued expression.
    At line:29 char:1
    + $CurrentGroup.AgentsByUri.Remove("$newuser")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Set-CsRgsAgentGroup : Cannot validate argument on parameter 'Instance'. The argument is null. Provide a valid value for the argument, and then try running the command again.
    At line:31 char:31
    + Set-CsRgsAgentGroup -Instance $Currentgroup
    +                               ~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Set-CsRgsAgentGroup], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Rtc.Rgs.Management.SetOcsRgAgentGroupCmdlet


    Mohammed JH

    Friday, July 13, 2018 8:06 PM