You can perform searches in Yammer as described here. The snippet below shows how you can perform a search. The search returns multiple objects:

  • Messages
  • Users
  • Topics
  • Uploaded files
  • Users

You can generate the baerer token (access token) as described in this post.

Always consider the REST API and Rate Limits when accessing a Yammer network.

$baererToken = "Put your baerer token here"
$searchQuery = "searchQuery"
$yammerBaseUrl = "https://www.yammer.com/api/v1"
Function Get-BaererToken() {
$headers = @{ Authorization=("Bearer " + $baererToken) }
return $headers
}
$headers = Get-BaererToken
$baseUrl = "$($yammerBaseUrl)/search.json"
$currentResult = $null
$groups = @()
$messages = @()
$topics = @()
$uploadedFiles = @()
$users = @()
$summary = $null
$page = 0
do {
$page++
$query = "$($baseUrl)?search=$($searchQuery)&page=$($page)"
Write-Host $query
$currentResult = Invoke-RestMethod -ContentType 'application/json;odata=nometadata' –Uri $query –Method Get -Headers $headers
$hasSearchResults = $false
if ($currentResult -ne $null) {
if ($summary -eq $null) {
$summary = $currentResult.count
}
if ($currentResult.messages.messages.Count -gt 0) {
$hasSearchResults = $true
$messages += $currentResult.messages.messages
}
if ($currentResult.groups.Count -gt 0) {
$hasSearchResults = $true
$groups += $currentResult.groups
}
if ($currentResult.topics.Count -gt 0) {
$hasSearchResults = $true
$topics += $currentResult.topics
}
if ($currentResult.users.Count -gt 0) {
$hasSearchResults = $true
$users += $currentResult.users
}
if ($currentResult.uploaded_files.Count -gt 0) {
$hasSearchResults = $true
$uploaded_files += $currentResult.uploaded_files
}
}
}
while ($hasSearchResults)
Write-Host "Summary..."
$summary
Write-Host "Messages..."
$messages
Write-Host "Groups..."
$groups
Write-Host "Topics..."
$topics
Write-Host "Uploaded files..."
$uploadedFiles
Write-Host "Users..."
$users
view raw gistfile1.txt hosted with ❤ by GitHub