Find All Office 365 Group Owners using PowerShell
Requirement: Get Office 365 Group Owners
How to Get Office 365 Group Owners?
To get Office 365 group owners from Microsoft 365 admin center,
Get Office 365 Group Owners using PowerShell:
The script connects to Exchange Online and gets group owners of a given Office 365 group "[email protected]".
Find All Office 365 Group Owners using PowerShell:
To get owners of all Office 365 groups and export to CSV, use:
Find Owners of an Office 365 Group using Azure AD PowerShell:
Make sure you have "Azure AD" PowerShell Module installed before running this script!
PowerShell to Generate Group Owners Report from Azure AD
How to Get Office 365 Group Owners?
To get Office 365 group owners from Microsoft 365 admin center,
- Login to the Microsoft 365 Admin Center site: https://admin.microsoft.com
- Expand Groups and Click on Groups link in the left navigation.
- The groups page lists all groups in your Office 365 tenant. Pick the desired group to list owners of the group.
- This opens the group's details page which lists group Owners
Get Office 365 Group Owners using PowerShell:
The script connects to Exchange Online and gets group owners of a given Office 365 group "[email protected]".
#Get Credentials to connect $Credential = Get-Credential #Create the session $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ ` -Credential $Credential -Authentication Basic -AllowRedirection #Import the session Import-PSSession $Session -DisableNameChecking | Out-Null #Get Owners of a Office 365 Group Get-UnifiedGroup -Identity "[email protected]" | Get-UnifiedGroupLinks -LinkType Owner | Select DisplayName, PrimarySmtpAddress #Remove the session Remove-PSSession $Session
Find All Office 365 Group Owners using PowerShell:
To get owners of all Office 365 groups and export to CSV, use:
#Get Credentials to connect $Credential = Get-Credential #Create the session $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ ` -Credential $Credential -Authentication Basic -AllowRedirection #Import the session Import-PSSession $Session -DisableNameChecking | Out-Null #Get All Office 365 Groups $GroupData = @() $Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name #Loop through each Group $Groups | Foreach-Object { #Get Group Owners $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 "; " } } #Get Groups Data $GroupData $GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation #Remove the session Remove-PSSession $Session
Find Owners of an Office 365 Group using Azure AD PowerShell:
Make sure you have "Azure AD" PowerShell Module installed before running this script!
#Connect to AzureAD Connect-AzureAD -Credential (Get-Credential) | Out-Null #Get Group Owners Get-AzureADGroupOwner -ObjectId (Get-AzureADGroup -SearchString "Purchase").ObjectId
PowerShell to Generate Group Owners Report from Azure AD
#Get Credentials to connect $Cred = Get-Credential #Connect to AzureAD Connect-AzureAD -Credential $Cred | Out-Null $GroupData = @() #Get all Office 365 Groups Get-AzureADMSGroup -Filter "groupTypes/any(c:c eq 'Unified')" -All:$true | ForEach-object { $GroupName = $_.DisplayName #Get Owners $GroupOwners = Get-AzureADGroupOwner -ObjectId $_.ID | Select UserPrincipalName, DisplayName $GroupData += New-Object PSObject -Property ([Ordered]@{ GroupName = $GroupName OwnerID = $GroupOwners.UserPrincipalName -join "; " OwnerName = $GroupOwners.DisplayName -join "; " }) } #Export Group Owners data to CSV $GroupData $GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformationScript Output:
No comments:
Please Login and comment to get your questions answered!