Is there a powershell script that can export all (Viva engage) yammer user data prior to the network migration to sharepoint?

Anonymous
2025-02-05T17:53:14+00:00

Hi,

MS is merging all the yammer networks into sharepoint.
That said, they say to backup the users data but the export tool in the admin page does 1 user at a time.

Is there a powershell script that can do this?

Microsoft 365 and Office | Microsoft Viva | Viva Engage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2025-02-06T05:17:54+00:00

Hi Justin Losier ,

Thank you for reaching out.

Yes, Microsoft is indeed merging all Yammer networks into SharePoint. You can script this with PowerShell by making API requests, but this would require authentication and some custom development. Here are detail steps.

  1. Go to https://www.yammer.com/client_applications to create an App and generate the token.

Image

Image

Image

  1. Enter the token in below script.

Script for exporting Users:

$AccessToken = "YOUR_ACCESS_TOKEN"
$Headers = @{
    "Authorization" = "Bearer $AccessToken"
}

# API endpoint to get all users
$UsersApiUrl = "https://www.yammer.com/api/v1/users.json"

# Fetch users from API
$Users = Invoke-RestMethod -Uri $UsersApiUrl -Headers $Headers -Method Get

# Extract relevant details
$UserData = $Users | ForEach-Object {
    [PSCustomObject]@{
        ID = $_.id
        Name = $_.full_name
        Email = $_.email
        JobTitle = $_.job_title
        Department = $_.department
        State = $_.state
        JoinedAt = $_.activated_at
    }
}

# Export to CSV
$UserData | Export-Csv -Path "YammerUsers.csv" -NoTypeInformation

Write-Host "User data has been exported successfully to YammerUsers.csv."

Note:

  • Replace "YOUR_ACCESS_TOKEN" with a valid OAuth token.
  • Run the script in PowerShell.
  • It will generate a YammerUsers.csv file containing user details.

Script for exporting groups:

# PowerShell script to export Yammer groups, members and admins
# Token hint: https://support.office.com/en-us/article/export-yammer-group-members-to-a-csv-file-201a78fd-67b8-42c3-9247-79e79f92b535#step2
# Token hint2: https://www.yammer.com/client_applications
# Pre-requisite: Enable Private Content Mode so the export includes private groups you're not a member of
# Remember to clean up token & revert Content Mode when complete
 
# Set variables
$Token = "21XXXXXXXXX-0erMknXXXXXXX7ORqr0w"
 
$Headers = @{
"Authorization" = "Bearer "+$Token
}
 
# Get a list of Yammer groups. Calls in pages as each search is limited to 50 results
$GroupCycle = 1
DO {
 $GetMoreGroupsUri = " https://www.yammer.com/api/v1/groups.json?page=$GroupCycle"
 write-host ($GetMoreGroupsUri)
 $MoreYammerGroups = (Invoke-WebRequest -Uri $GetMoreGroupsUri -Method Get -Headers $Headers).content | ConvertFrom-Json
 $YammerGroups += $MoreYammerGroups
 $GroupCycle ++
 $GroupCount = $YammerGroups.Count
}
While ($MoreYammerGroups.Count -gt 0)
 
$YammerGroups | Export-Csv group-export.csv -NoTypeInformation
$YammerGroups | select type,id,full_name,privacy,created_at
 
# For each group, list the members and the admins. Calls in pages as each search is limited to 50 results
$GroupAdmins = @()
$GroupMembers = @()
$GroupSummary = @()
$GroupCount = 0
foreach ($group in $YammerGroups) {
 $GroupId = $group.id
   [string]$GroupCreatedAt = $group.created_at
 $GroupCycle = 1
   DO {
       if ($GroupCycle -eq 1) { $AdminCount = 0; $GroupCount = 0 }
 $GetGroupMembersUri = " https://www.yammer.com/api/v1/groups/$GroupId/members.json?page=$GroupCycle"
write-host ("REST API CALL : $GetGroupMembersUri")
 $MoreGroupMembers = ((Invoke-WebRequest -Uri $GetGroupMembersUri -Method Get -Headers $Headers).content | ConvertFrom-Json).users | select @{N='group_id';E={$group.id}},@{N='group_name';E={$group.full_name}}, @{N='group_privacy';E={$group.privacy}}, @{N='group_show_in_directory';E={$group.show_in_directory}}, @{N='group_created_at';E={$GroupCreatedAt}}, type, @{N='user_id';E={$_.id}}, full_name, email, state, is_group_admin
       foreach ($member in $MoreGroupMembers) {
           if ($member.is_group_admin -eq "True") {
 $GroupAdmins += $member
 $AdminCount ++
           }
 $GroupMembers += $member
 $GroupCount ++
       }
 $GroupCycle ++
  }       
While ($MoreGroupMembers.count -gt 0)
 $groupResult = @{
       Group_Name = $group.full_name
       ID = $group.id
       State = $group.state
       Privacy = $group.privacy
      Show_In_Directory = $group.show_in_directory
       Created = $group.created_at
       Member_Count = $GroupCount
       Admin_Count = $AdminCount
   }
 $groupObject = New-Object -TypeName PSObject -Property $groupResult
 $groupSummary += $groupObject
 #$groupSummary += $groupResult
 write-output $groupObject
}
 
# Export the results to CSV files
$groupSummary | Select Group_Name, ID, State, Privacy, Show_In_Directory, Created, Member_Count, Admin_Count | export-csv group-summary.csv -NoTypeInformation
$groupAdmins | export-csv group-admin-export.csv -NoTypeInformation
$groupMembers | export-csv group-member-export.csv -NoTypeInformation

Manual Export:

In addition to script, you can also try a manual approach, you can export the tenant data from the "Export Network Data" section and filter the data as needed.

For more detailed information, you can refer to the Yammer Network Data Export documentation

Image

Thank you very much.

Best Regards,
Community Moderator | Sophia

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2025-02-06T12:45:14+00:00

    Wow thank you so much for your time to reply :)

    Was this answer helpful?

    0 comments No comments