none
Trying to write a powershell script to list the 365 groups and the number of users in the groups. RRS feed

  • Question

  • Banging my head against the wall with this one.. I just need a list of the groups in 365 and number of users within the groups. 

    So far I've tried this... 

    get-unifiedgroup |  format-list displayname.count

    But it only spits out blank data.  

    any ideas? 

    thank you! 

    Monday, August 28, 2017 5:32 PM

Answers

  • Hi Clintster010 

    I have used this script before to get all group and a membership count. 

    $groups = Get-MsolGroup -All
    foreach ($group in $groups){
    $group | select DisplayName,GroupType,@{Name="MemberCount";E={(Get-MsolGroupMember -GroupObjectId $group.ObjectId).count}} |
    Export-Csv C:\temp\MSOLGroupMembercount.csv -Append -NoTypeInformation 
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Monday, August 28, 2017 7:29 PM

All replies

  • The Get-UnifiedGroup cmdlet does not retrieve members. Perhaps pipe the group names to the Get-UnifiedGroupLinks cmdlet. See this link:

    https://technet.microsoft.com/en-us/library/mt238273(v=exchg.160).aspx

    Use "-LinkType Members" (as in example 1), which probably supports the Count property.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, August 28, 2017 6:20 PM
    Moderator
  • Hi Clintster010 

    I have used this script before to get all group and a membership count. 

    $groups = Get-MsolGroup -All
    foreach ($group in $groups){
    $group | select DisplayName,GroupType,@{Name="MemberCount";E={(Get-MsolGroupMember -GroupObjectId $group.ObjectId).count}} |
    Export-Csv C:\temp\MSOLGroupMembercount.csv -Append -NoTypeInformation 
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Monday, August 28, 2017 7:29 PM