How To Get The Number Of Followers And Following For A Specific User In Yammer Using PowerShell

In this blog, you will see how to get the number of followers and following for a specific user in Yammer using PowerShell.

In this blog, you will see how to get the number of followers and following for a specific user in Yammer 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 GetFollowers.ps1.

  1. # Input Parameters  
  2. $developerToken = "12240-******PR2NWpZVtnbXYw"  
  3. $userID="1511586543"  
  4. $uri="https://www.yammer.com/api/v1/users/"+$userID+".json"  
  5. $headers = @{ Authorization=("Bearer " + $developerToken) }  
  6.   
  7. # Invoke Web Request  
  8. $webRequest = Invoke-WebRequest –Uri $uri –Method Get -Headers $headers  
  9.   
  10. Check whether the status code is 200  
  11. if ($webRequest.StatusCode -eq 200) {  
  12.   
  13.     # Converts a JSON-formatted string to a custom object or a hash table.   
  14.     $user = $webRequest.Content | ConvertFrom-Json  
  15.       
  16.     write-host -ForegroundColor Magenta "Followers: " $user.stats.followers " Following: " $user.stats.following  
  17. }  
  18. else {  
  19.     Write-Host -ForegroundColor Yellow "An error has occurred: " + $webRequest.StatusCode + " Description " + $webRequest.Status  
  20. }  

Open PowerShell window and run the following command.

  1. >cd "<folderlocation>"  

folderlocation – GetFollowers.ps1 file location

Run the following command

  1. >.\GetFollowers.ps1  

Thus in this blog, you saw how to get the number of followers and following for a specific user in Yammer using PowerShell.