Last active
June 29, 2020 03:04
-
-
Save Atreidae/15caa46848f5c761a1001d65929095b3 to your computer and use it in GitHub Desktop.
Remove user from Response Groups in Skype for Business and Lync,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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