How To Remove A User From A Specific Yammer Group Using PowerShell

In this blog, you will see how to remove a user from a specific Yammer group using PowerShell.

Prerequisites

Go to https://www.yammer.com/client_applications and register an app.

Once the app is registered, generate a developer token.

 

Copy the below script and paste it in a notepad. Save the file as RemoveUser.ps1.

  1. # Input Parameters  
  2. $developerToken = "12240-*****iPR2NWpZVtnbXYw"  
  3. $groupID="15653442"  
  4. $userID="1541035765"  
  5. $uri="https://www.yammer.com/api/v1/group_memberships.json?group_id=" + $groupID + "&user_id=" + $userID  
  6. $headers = @{ Authorization=("Bearer " + $developerToken) }  
  7.   
  8. # Invoke Web Request - Remove the user from Specific group  
  9. $webRequest = Invoke-WebRequest –Uri $uri –Method Delete -Headers $headers  

 Open PowerShell window and run the following command. 

  1. >cd "<folderlocation>"  

 folderlocation – RemoveUser.ps1 file location

Run the following command,

  1. >.\RemoveUser.ps1  

Thus in this blog, you saw how to remove a user from specific Yammer group using PowerShell.