In this blog, you will see how to get all of the Yammer groups 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 Groups.ps1.
- # Input Parameters
- $developerToken = "12240-*****PR2NWpZVtnbXYw"
- $uri="https://www.yammer.com/api/v1/groups.json"
- $headers = @{ Authorization=("Bearer " + $developerToken) }
-
- # Invoke Web Request
- $webRequest = Invoke-WebRequest –Uri $uri –Method Get -Headers $headers
-
- # Check whether the status code is 200
- if ($webRequest.StatusCode -eq 200) {
-
- # Converts a JSON-formatted string to a custom object or a hash table.
- $results = $webRequest.Content | ConvertFrom-Json
-
- write-host -ForegroundColor Magenta "Groups Count: " $results.length
-
- # Loop through all the groups
- $results | ForEach-Object {
- $group = $_
- # Display the group name and members count
- Write-Host -ForegroundColor Green "Group Name: " $group.full_name " - Members: " $group.stats.members
- }
- }
- else {
- Write-Host -ForegroundColor Yellow "An error has occurred: " + $webRequest.StatusCode + " Description " + $webRequest.Status
- }
Open PowerShell window and run the following command.
folderlocation – Groups.ps1 file location.
Run the following command.
Thus in this blog, you saw how to how to get all the Yammer groups using PowerShell.