For Office 365, you could use the script below to check it:
$musers = import-csv "C:\temp\userlist.csv"
$groups = Get-UnifiedGroup -ResultSize Unlimited
$Data = @()
foreach ($muser in $musers) {
foreach($group in $groups){
if ($group.ManagedBy -contains (Get-Mailbox $muser.Name).Name){
$Data += Get-UnifiedGroup $group.name | select DisplayName,PrimarySMTPAddress,Notes,managedby
}
}
}
$Data | Export-Csv C:\temp\unifiedgroups.csv -NoTypeInformation
For distribution group, you could use the script below to check:
$musers = import-csv "C:\temp\userlist.csv"
$groups = Get-DistributionGroup -ResultSize Unlimited
$Data = @()
foreach ($muser in $musers) {
foreach($group in $groups){
if ($group.ManagedBy -contains (Get-Mailbox $muser.Name).Name){
$Data += Get-DistributionGroup $group.name | select DisplayName,PrimarySMTPAddress,Notes,managedby
}
}
}
$Data | Export-Csv c:\temp\DistributionLists.csv -NoTypeInformation
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.