Sep 15 2016 01:04 PM - edited Sep 15 2016 01:07 PM
Sep 15 2016 01:04 PM - edited Sep 15 2016 01:07 PM
(Broken into 2 parts because of character limit)
Group administrators are an important target for internal marketing for Yammer adoption. There’s no documented way to get them, but obviously it can be done, since within each group there are a list of accounts with a star within the picture. The secret is a currently undocumented API:
This API returns the first 50 accounts of a group, listing the administrators first. The output has a ton of columns, but the important one is a flag, Is User Admin. If it’s true, then the account listed is an administrator of the group.
So I wrote a script for you. It’s a mix of old-school batch and VBS (visual basic scripting) scripting, along with some PowerShell. Very old school. But it does work, and if your Excel happens to be in the same directory as mine, it’ll open right up with an Excel spreadsheet. If not, you just go into the directory where you ran this and open up the AllGroups.xml file in your Excel.
1.) Take the the text below, save it as a text file.
2.) Create a list of Group IDs you want to evaluate. Do an export, check out groups.csv, and sort on the deleted field. Pick the ones that aren’t deleted and create a csv file called Groups.csv. You could technically use the export one but I do recommend you trim it out to just include the non-deleted ones. It’ll have a format just like the Groups.csv file attached to this post.
3.) You need something called a REST token. Two things to know about this.
First – be careful with this token. Guard it. It’s the security equivalent of your username and password. And since you’re probably a Yammer Verified Admin, someone finding and using this token could really be a big problem for your network.
Second – this process is a pain. Seriously. I’ll try to write a script to make it easier, but for now, unfortunately, the best available documentation is here: https://developer.yammer.com/docs/test-token
I’ll wait while you read that. And yes, like I said, it is a pain. Sorry.
When you’re done, you’ll have your token. It’ll be something like this: GwrtnFHPU59EL1CUFeuEbe
Ok, that is literally the hardest part of this whole process. Don’t be embarrassed asking for help from your local developers or the Yammer Developer group.
4.) Find a directory on your hard drive with no spaces in the path – preferably make a new one, called C:\Yammer\Data or something like that. Copy the Groups.csv file and the new batch file into the same directory. The new batch file is a text file – start Notepad, copy in all the text below, and save it as a file. On the hard drive, rename it to have a .bat extension.
5.) Open a command prompt if you know how, change to the directory where those two files are, and type in the name of the name of the batch file you created in Step 1. If you don’t know how, that’s fine, just double-click the batch file. If it just comes back in Notepad, your computer isn’t letting you see the extension. Try opening up Explorer, hitting View, and selecting the File name extensions. Then you can switch the file name from .txt to .bat.
6.) You’ll be prompted for your token. Paste the token you got in step 3. Remember never ever let anyone have it. This batch will ask every time you run it. After you enter it, you’ll get a message to confirm what you just entered.
7.) The file will run through each group and query the group for the first 50 users, naming the admins first. You’ll see all kinds of stuff going on across the command screen. The actual data is put into a created subdirectory called GetGroupAdmins\Output. If you’re lucky and I have the path right for your Excel installation, literally after you paste in the REST token, you don’t have to touch anything until the last bit.
8.) Excel loads – if it doesn’t just open Excel manually and tell it to open GetGroupAdmins\Output\AllGroups.xml. Excel will ask you what to do with the XML document. Choose the default, to open it as an XML table. Then you’ll be warned that there isn’t an existing schema, but Excel will make one for you. That’s exactly what you want, so go ahead and just hit Ok again. Finally, you’ll get a warning that some data was imported as text. Again, we want that, so hit Ok again.
9.) The result is a full workbook with just about all the information available about your group. Each row is a user. The group name, email address, ID, etc. is repeated on each user row; this helps for reporting. Column number AZ is called “is-group-admin”. This is the true / false field that denotes if the user row is an administrator for that group. You can filter in Excel to only include the True items. This will create a usable list for you. Column AY (the one immediately preceding) is the email address for each user.
10.) Save the file. Feel free to make copies of it, delete columns, etc. When you need to re-run it, just repeat the process. You can do this forever.
(Note that Eric Jenouvrier has a more elegant solution for the 50 item limit here.)
Sep 16 2016 03:53 AM
Do you need to be a verified admin to do this? Or can a group admin do this in their groups they manage?
Sep 16 2016 06:34 AM - edited Sep 16 2016 06:35 AM
Sep 19 2016 08:07 AM
Tom, can you estimate the time to complete this for 1 group?
Thanks for writing up these instructions - I'm slowly getting hip to developer language. :)
Jan 24 2017 01:08 PM
@Tom Kretzmer, you said that you need to have read access to the groups to be able to extract this data - if you are an admin in Private Content mode, can you pull the administrator data from private groups?
Apr 16 2017 12:21 AM
Brilliant guide. Ran into some trouble with my groups.csv, as my separator was set to ; instead of , but, once I changed that, it ran like a charm.
One question though, is there an easier way to extract the list of all groups rather than doing a full data export? As our network grows, that extract is becoming painful.
Apr 21 2017 11:59 AM
I'm so glad to hear that this worked for you!! :) Excellent!
That's a good question. Really, all you need is a list of Group ID's from your network. Your old groups are probably static, so if I were you I'd try to do an export with a start date set to the day before you did your last export. That will make the result download a lot smaller, and you can just add the new Group ID's to the list you already have.
Also, give this a try:
That will give you an XML file of groups; I'm not sure if it's all groups in the network or all the groups to which you have access.
If you'd like help handling that XML file let me know.
That lovely undocumented API is courtesy of @Benjamin Elias
Apr 21 2017 02:02 PM
Apr 23 2017 09:27 PM
Benjamin, indeed, the API returns the first 50 groups, so pagination in my 900 group network is required :)
Apr 24 2017 02:16 PM
@Eric JENOUVRIER has a script using a Do While loop that manages group members over 50, which accounts for the pagination. See if you can morph it to your needs.
Apr 25 2017 03:29 AM
One more question: how to get this to work for an external network? Is it just a question of generating a token on the external network?
I'm off to investigate, but any insights are welcome.
Apr 25 2017 03:38 AM
Apr 25 2017 04:29 AM
While in my external network, I registered a new app, and that generated a token which worked like a charm. :)
Apr 27 2017 08:38 PM
Aug 23 2017 04:08 PM
I get the following error repeated when i run the batch... any help would be appreciated.
Invoke-WebRequest : The remote server returned an error: (404) Not Found.
At C:\Yammer\GetGroupAdmins\GetAdmins.ps1:24 char:2
+ (Invoke-WebRequest -Uri $uri -Method Get -Headers $Headers -passthru ...
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Aug 23 2017 04:13 PM
Oct 19 2017 12:09 AM
The error looks to be due to the reason that group is Private and you are not the member of that group, as indicated on this thread earlier the person running this must be able to authenticate the group. I had tried with Verified Admin and still it fails. Are there any workarounds for this ?