Get-MgmtGraphGroupOwnerCount
MgmtGraph: Retrieves group owner counts by type
#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Groups
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, Position = 0)]
[string]$GroupId,
[ValidateSet('AsApplication', 'AsDevice', 'AsGroup', 'AsOrgContact', 'AsServicePrincipal', 'AsUser')]
[string]$ResultType
)
Process {
try {
$params = @{
'GroupId' = $GroupId
'ConsistencyLevel' = 'eventual'
'ErrorAction' = 'Stop'
}
$count = $null
if ($ResultType) {
switch ($ResultType) {
'AsApplication' {
$count = Get-MgGroupOwnerCountAsApplication @params
}
'AsDevice' {
$count = Get-MgGroupOwnerCountAsDevice @params
}
'AsGroup' {
$count = Get-MgGroupOwnerCountAsGroup @params
}
'AsOrgContact' {
$count = Get-MgGroupOwnerCountAsOrgContact @params
}
'AsServicePrincipal' {
$count = Get-MgGroupOwnerCountAsServicePrincipal @params
}
'AsUser' {
$count = Get-MgGroupOwnerCountAsUser @params
}
}
}
else {
$count = Get-MgGroupOwnerCount @params
}
$result = [PSCustomObject]@{
GroupId = $GroupId
TypeFilter = if ($ResultType) { $ResultType } else { 'All' }
OwnerCount = $count
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $result
}
catch {
throw
}
}The unique identifier of the Microsoft Graph group.
Optional. The type of group owners to count. Supported values: AsApplication, AsDevice, AsGroup, AsOrgContact, AsServicePrincipal, AsUser.