Skip to content

Instantly share code, notes, and snippets.

@Atreidae
Last active June 29, 2020 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Atreidae/15caa46848f5c761a1001d65929095b3 to your computer and use it in GitHub Desktop.
Save Atreidae/15caa46848f5c761a1001d65929095b3 to your computer and use it in GitHub Desktop.
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