Techcommunity.microsoft.com



Delete Pending AccountsTom Kretzmer 29 January 2016I 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 . 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 = "$user.json?delete=true"Write-Host $uri(Invoke-WebRequest -Uri $uri -Method Delete -Headers $Headers).content | ConvertFrom-Json } ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download