For Unified Group:
$groups = Get-UnifiedGroup -ResultSize Unlimited
$Data = @()
foreach($group in $groups){
$Data += Get-UnifiedGroup $group.name | select DisplayName,PrimarySMTPAddress,Notes,managedby
}
$Data | Export-Csv C:\temp\unifiedgroups.csv -NoTypeInformation
For distribution group:
$groups = Get-DistributionGroup -ResultSize Unlimited
$Data = @()
foreach($group in $groups){
$Data += Get-DistributionGroup $group.name | select DisplayName,PrimarySMTPAddress,Notes,managedby
}
$Data | Export-Csv c:\temp\DistributionLists.csv -NoTypeInformation
By the way, if the previous script was useful, I suggest you accept it as an answer to help more users. If it doesn't work, I suggest you continue the discussion under the previous post. Asking the same question multiple times is not good for other community members reading.
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.