Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove user from Response Groups in Skype for Business and Lync,
#Skype User Offboarding Response Group Cleanup. UcMadScientist.com
#Define user account
$SipAddress = "Button.Mash@EquestriAero.com"
#Create an array of response groups containing the user
$RGSGroups = (Get-CsRgsAgentGroup | where {$_.AgentsByuri -contains "Sip:$SipAddress"})
#Run through the groups and remove the user
ForEach ($Group in $RGSGroups)
{
Write-output "User found in $($Group.Name). Removing..."
Try
{
[void]($Group.AgentsByUri.Remove("sip:$SipAddress"))
Set-CsRgsAgentGroup -Instance $Group
Write-output "User removed from $($Group.Name)."
}
Catch
{
Write-error "Error: Something went wrong removing the user from $($group.name)"
}
#Check if we left the response Group Empty
if ($Group.AgentsByUri.Count -eq 0) {Write-Warning "$SipAddress was the last user in $($Group.name). This response group will not function until another user is added!"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.