How To Add A User To Yammer Group Using PowerShell

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

  1. # Input Parameters    
  2. $developerToken = "461-******YOkutfuKoWUEmWPg"   
  3. $uri="https://www.yammer.com/api/v1/group_memberships.json"  
  4. $headers = @{ Authorization=("Bearer " + $developerToken) }     
  5. $body=@{group_id="8010451";email="Manpreet@xxxxxxx.com"}   
  6.   
  7. # Invoke Web Request - Add user to Group  
  8. $webRequest = Invoke-WebRequest –Uri $uri –Method POST -Headers $headers -Body $body    
  9.     
  10.       

Open PowerShell window and run the following command.

  1. >cd "<folderlocation>"

folderlocation – AddUserToGroup.ps1 file location

Run the following command.

  1. >.\AddUserToGroup.ps1

Reference

https://developer.yammer.com/docs/group_membershipsjsongroup_idid

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