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.
- # Input Parameters
- $developerToken = "461-******YOkutfuKoWUEmWPg"
- $uri="https://www.yammer.com/api/v1/group_memberships.json"
- $headers = @{ Authorization=("Bearer " + $developerToken) }
- $body=@{group_id="8010451";email="[email protected]"}
-
- # Invoke Web Request - Add user to Group
- $webRequest = Invoke-WebRequest –Uri $uri –Method POST -Headers $headers -Body $body
-
-
Open PowerShell window and run the following command.
folderlocation – AddUserToGroup.ps1 file location
Run the following command.
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.