Owner Count

Steel Contributor

a stupid question.

i can't find a way to retrieve the amount of owners of a group.

 

a group can have max 10 owners so therefore i'm heavily interested in this number

ManagedBy (Get-UnifiedGroup) would give me the name of the owners. So should i just count the names of this key, then ? 🙂

 

I wanna correlate this information further with orphaned user accounts.

 

 

7 Replies

Hi Stefan,

Try below query

Get-UnifiedGroup |select displayname,ManagedByDetails,@{N="Owner count"; E={($_.ManagedByDetails.count)}}

thanks manidurai

 

so as expected --> i have to count the "ManagedBy" or "ManagedByDetails" entried :)))

 

but thanks for creating the query

Well, you can get the same info via other methods, for example:

 

Get-UnifiedGroupLinks groupname -LinkType Owner

 

There is no prebuilt property if that's what you are asking for.

Hi stefan 
Sorry I can’t understand your question , I have already given a query to list entire office 365 groups with entire owners (Mangedby or Mangedbydetails )count
Or
If you want name of all owners of a group you try with vasil query
Or
If you want Find office 365 groups list by specific owner in tenant try following query

$Ownername = "AlexW"
$groups = Get-UnifiedGroup -ResultSize Unlimited |select displayname,ManagedByDetails
$i=0
$groupname = ''
Foreach($group in $groups)
{
    $Gname= $group |Where-Object {$group.ManagedByDetails -eq "$Ownername"} |select displayname
    If($Gname -ne $null)
    {
        $j =1
        $i = $j +$i
        If($groupname)
        {
          $groupname= $groupname+","+$Gname.displayname.ToString()

        }
        else
        {
          $groupname= $Gname.displayname.ToString()

        }

    }
}
Write-host "$($Ownername) was owner of $($i) Groups"
Write-host "$($Ownername) was owner of following Groups : $($groupname)" 


Or
If you want total number of owner in tenant try following query

$mboxs= get-mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox
$L =0
Foreach($mbox in $mboxs)
{
    $groups = Get-UnifiedGroup -ResultSize Unlimited |select displayname,ManagedByDetails,@{N="Ownercount"; E={($_.ManagedByDetails.count)}}

    $i=0
    $groupname = ''
    Foreach($group in $groups)
    {
        $Gname= $group |Where-Object {$group.ManagedByDetails -eq $mbox.Identity} |select displayname
        If($Gname -ne $null)
        {
            $j =1
            $i = $j +$i
            If($groupname)
            {

            $groupname= $groupname+","+$Gname.displayname.ToString()

            }
            else
            {
            $groupname= $Gname.displayname.ToString()
            }

        }
    }
    

    if($i -ne 0)
    {
    $K=1
    $L = $L+$k
    Write-host "$($mbox.Identity) was owner of $($i) Groups"
    Write-host "$($mbox.Identity) was owner of following Groups :"  -NoNewline
    Write-host "$($groupname)" -ForegroundColor Red 
    Write-host "----------------------------------------------------------------" -ForegroundColor Green
    }

}
Write-Host "Total number of office 365 group owners in the tenant is $($L)" -ForegroundColor Yellow

 

 

Please try this sample PS cmdlet:

 

Get-UnifiedGroup | Select Id, DisplayName,
@{Expression={([array](Get-UnifiedGroupLinks -Identity $_.Id -LinkType Owners)).Count }; Label='Owners'} | Sort-Object Owners -Descending | Format-Table displayname, Owners

thank you all for all the Powershell Script contributions. I really appreciate!

 

i thought that a prebuilt property exists but in fact it does not.

I was also hoping to get this owner count information via API and not necessarily via PS but it seems that PS is always the leading way

 

thanks again

I need to know rather say i need a report on Office 365 groups which shows the list of users who are owners of the group(s) , group names and group count

 

So the table should look like

 

user/owner name(UP/Email), Group Names, Group Count

 

Strange thing is your script does the similar but not in the tabular format however only shows two users whereas there are many owners in the Azure AD

 

BR,

/HS