Retrieve Microsoft 365 group owner

  • Last update on September 26th, 2024

Custom actions are not available in the Essentials solution.

 

If you are looking for the owner of a Microsoft 365 group, you can use the following script:

In PowerShell:

#Connect to Exchange Online
Connect-ExchangeOnline -Credential (Get-Credential) -ShowBanner:$False
#Get Owners of a Office 365 Group
Get-UnifiedGroup -Identity "Purchase@Crescent.com" | Get-UnifiedGroupLinks -LinkType Owner | Select DisplayName, PrimarySmtpAddress
#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

In a CoreView custom action:

{
 "id": "68f88c15-937c-4129-98b2-4ff3285e4955",
 "title": "Get M365 group Owner",
 "lastModified": "2021-11-11T12:17:41.1850000Z",
 "target": "O365Group",
 "tags": [],
 "vars": [],
 "params": [
 {
 "name": "Name",
 "type": "string",
 "isDefault": true
 }
 ],
 "columns": {
 "Name": ""
 },
 "version": 5,
 "statement": "param ([string]$Name)\r\n\r\n$Manager = Get-UnifiedGroup $Name | select PrimarySmtpAddress, @{n= \"ManagedBy\"; e={$_.ManagedBy | foreach {(Get-Mailbox $_).PrimarySMTPAddress}}}\n$M365GroupOwner = $Manager.ManagedBy\n\n$json = @\"\n{\n\"OwnerEmailAddress\": \"$M365GroupOwner\"\n}\n\"@ \nreturn $json"
}