Obtenir les propriétaires d’un groupe Teams / Microsoft 365

  • Last update on May 30th, 2025

Les actions personnalisées ne sont pas disponibles dans la solution Essentials.

 

Si vous devez obtenir la liste des propriétaires d’un groupe Microsoft 365 ou Teams donné à partir de son guid/identifiant, vous pouvez utiliser le script suivant :

En PowerShell :

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Install-Module -Name ExchangeOnlineManagement -Verbose -Force
Update-Module -Name ExchangeOnlineManagement -Verbose -Force
Connect-ExchangeOnline -UserPrincipalName <votre.nom@domain.com>
$GroupData = @()
$Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name
$Groups | Foreach-Object {
# Récupérer les propriétaires du groupe
$GroupOwners = Get-UnifiedGroupLinks -LinkType Owners -Identity $_.Id | Select DisplayName, PrimarySmtpAddress
$GroupData += New-Object -TypeName PSObject -Property @{
GroupName = $_.Alias
GroupEmail = $_.PrimarySmtpAddress
OwnerName = $GroupOwners.DisplayName -join "; "
OwnerIDs = $GroupOwners.PrimarySmtpAddress -join "; "
}
}
$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation
Disconnect-ExchangeOnline -Confirm:$false

OU :

$Cred = Get-Credential
Install-Module -Name AzureAD -AllowClobber -Force -Verbose
Import-Module AzureAD
Connect-AzureAD -Credential $Cred | Out-Null
$GroupData = @()
Get-AzureADMSGroup -Filter "groupTypes/any(c:c eq 'Unified')" -All:$true | ForEach-object {
$GroupName = $_.DisplayName
$GroupOwners = Get-AzureADGroupOwner -ObjectId $_.ID | Select UserPrincipalName, DisplayName
$GroupData += New-Object PSObject -Property ([Ordered]@{
GroupName = $GroupName
OwnerID = $GroupOwners.UserPrincipalName -join "; "
OwnerName = $GroupOwners.DisplayName -join "; "
})
}
$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation
Disconnect-AzureAD

Dans une action personnalisée CoreView :

{
"id": "9824084b-7738-4e28-bebf-a1f9aeb38822",
"title": "Teams - Get Group Owners - V5",
"description": "Lists the owners of a given M365 Group / Teams Group based on the Group guid / Identity attribute",
"lastModified": "2022-02-04T20:36:22.1940000Z",
"target": "O365Group",
"tags": [],
"vars": [
{
"name": "GroupGUID",
"type": "string",
"isRequired": true
}
],
"params": [
{
"name": "Name",
"type": "string",
"isDefault": true
}
],
"columns": {
"Name": ""
},
"version": 5,
"statement": "param ([string]$Name, [string]$GroupGUID)\r\n\r\n$Group = Get-UnifiedGroup -Identity $GroupGuid | Get-UnifiedGroupLinks -LinkType Owner | Select PrimarySmtpAddress\n\n$GroupOwners = $Group.PrimarySmtpAddress -join ', ' \n\n$json= @\"\n{\n\"GroupOwners\": \"$GroupOwners\"\n}\n\"@\n\nreturn $json"
}