How To Delete A Yammer Group Using PowerShell

In this blog, you will see how to delete a 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 DeleteGroup.ps1.

  1. # Input Parameters  
  2. $developerToken = "12240-gSRfpiPR2NWpZVtnbXYw"  
  3. $groupID="15643324"  
  4. $uri="https://www.yammer.com/api/v1/groups/" + $groupID +".json"  
  5. $headers = @{ Authorization=("Bearer " + $developerToken) }  
  6.   
  7. # Invoke Web Request  
  8. $webRequest = Invoke-WebRequest –Uri $uri –Method Delete -Headers $headers  
  9.   
  10. Check whether the status code is 200  
  11. if ($webRequest.StatusCode -eq 200) {  
  12.       
  13.     write-host -ForegroundColor Green $groupID " group deleted successfully"  
  14. }  
  15. else {  
  16.     Write-Host -ForegroundColor Yellow "An error has occurred: " + $webRequest.StatusCode + " Description " + $webRequest.Status  
  17. }  

 Open PowerShell window and run the following command.

  1. >cd "<folderlocation>"  

folderlocation – DeleteGroup.ps1 file location

Run the following command

  1. >.\DeleteGroup.ps1  

Thus in this blog, you saw how to delete a Yammer group using PowerShell.