Sep 15 2016 09:43 AM
I wrote a little powershell app to remove pending users. I manually run a user export, and then in Excel I sort by status, then deleted_at, and then ID.
See, when someone is invited, that account is in a pre-active state until the account is verified by the user responding to the invitation email. If that person never activates or never uses Yammer, then the account will stay in pending status for a very long time. Additionally, that pending user will be suggested in the right navigation in the second slot, as an engagement feature of Yammer (encouraging the tentative to be invited again).
A normal admin function is to clean this list out from time to time. You don't want to delete the fresh invitations, so you choose to get rid of the older ones who have been hanging out for a while. These are listed in your user export as any accounts with a status of soft_delete and have a blank deleted_at date. The third sort by ID is to get the older ones, since ID is assigned sequentially.
Couple ways to use this script. You can take your indicated accounts and put them into a text file; just make sure the first line says "id" (no quotes). Or you can delete the lines of your export of users you want to keep and just use the export file. I don't recommend this, because of the next paragraph.
ANY USER IDs IN THIS LIST ARE DELETED FOREVER. There is no getting them back, even by Microsoft. No amount of begging, pleading, or bribery will get them back. They're gone. Test test test.
To use:
1.) Build your target list as above (screenshot below). In the script, I saved the file as C:\Data\Yammer\Powershell\AncientPenders.csv. Welcome to use this path, as long as you make sure the path exists and the file is in that directory.
2.) Update <Your Token> with your actual token. If you don't know how to get one, go to https://developer.yammer.com/docs/test-token. It's a little bit confusing, good luck.
3.) Save this script as a text file (below) with the .ps1 file extension.
4.) Open up Windows PowerShell and run the script by typing .\<filename>.
$token = "<Your Token>" $Headers = @{ "Accept" = "*/*" "Authorization" = "Bearer "+$token "accept-encoding" = "gzip" "content-type"="application/json" "content-length" = "2" } #import User ID's that need removed. $users = import-csv C:\Data\Yammer\Powershell\AncientPenders.csv $users = $users.id #loop through all User ID's foreach ($user in $users){ $uri = "https://www.yammer.com/api/v1/users/$user.json?delete=true" Write-Host $uri (Invoke-WebRequest -Uri $uri -Method Delete -Headers $Headers).content | ConvertFrom-Json }
(Originally posted on the Office 365 Network 29 January, 2016.)
Mar 02 2017 06:26 AM
Tom - thanks for this great little script!
One question: From your experience - how long does it take until the removed user no longer appear in the "Suggested People" widget?
Mar 02 2017 01:23 PM
You're very welcome.
I've noticed some administrative actions in Yammer take a little bit of time to "take". If the account is still showing up after 24 hours, then there probably is an additional account to delete, or else they were re-added. Sometimes I've had to block the account to prevent them from being re-invited.
Should only be a few minutes, but if it's a few hours, you're still within the realm of normalcy, at least in my experience. I use 24 hours as my measuring stick.
Mar 03 2017 03:35 AM
Alright 24hrs have come and gone, so far so good - all of the users I deleted no longer show up.
But: There are still users showing up in the "Suggested People" widget who I don't want to show up.
The API endpoint providing those items seems to be this: https://www.yammer.com/api/v1/suggestions.json?type=contact_invite
The parameter "type" is important - it leads to the result being a couple of users with the state "pending".
What's interesting about them is they don't show up in the user export!
Did you come across this phenomenon as well?
I would go ahead and just delete those by the ID provided in the response JSON.
Mar 03 2017 06:51 AM
Wow, no, that is strange. However, I have wondered at the completeness of the user export. Whenever I think I see a deficiency, I re-check and it turns out that it's my error (limiting the date range), but still... So what I do now is I do a full export (no attachments), and I set the date to something like 1/1/1970, to ensure that I get all the data. The user export in that usually is completely solid. Might want to give that a go.
Nice find with that API. :)
May 10 2017 07:10 AM