Forum Discussion
mfranhind115
Aug 26, 2022Brass Contributor
powershell: how to get members of a distribution list
Hi all, my company have several domains under its tenant. Now I should get, for each domain under the tenant, the list of the members of every dsitribution list. if too hard, for me would be...
- Aug 27, 2022
I should have added this before posting above.
If you wanted to flatten the output into a very basic CSV file rather than do further work with the objects, you can do it like this:
.\Get-ExoDistributionListMembers.ps1 | ForEach-Object { $Group = $_; $Group.Members | ForEach-Object { $_ | Select-Object -Property @{n="GroupType"; e={ $Group.GroupType}}, @{n="GroupName"; e={ $Group.GroupName}}, MemberType, MemberAddress; } } | Export-Csv -Path ".\distributionLists.csv" -NoTypeInformation;Cheers,
Lain
LainRobertson
Aug 27, 2022Silver Contributor
I should have added this before posting above.
If you wanted to flatten the output into a very basic CSV file rather than do further work with the objects, you can do it like this:
.\Get-ExoDistributionListMembers.ps1 |
ForEach-Object {
$Group = $_;
$Group.Members |
ForEach-Object {
$_ | Select-Object -Property @{n="GroupType"; e={ $Group.GroupType}}, @{n="GroupName"; e={ $Group.GroupName}}, MemberType, MemberAddress;
}
} | Export-Csv -Path ".\distributionLists.csv" -NoTypeInformation;
Cheers,
Lain
mfranhind115
Aug 29, 2022Brass Contributor
thank you so much LAin!!!
appreciate!
appreciate!