July 2017
Intermediate to advanced
648 pages
31h 9m
English
The previous code sample will allow you to view the output in the shell. If you want to export this information to a CSV file, use the following code:
$report=foreach($i in Get-DistributionGroup -ResultSize Unlimited) {
Get-DistributionGroupMember $i -ResultSize Unlimited |
Select-Object @{n="Member";e={$_.Name}},
RecipientType,
@{n="Group";e={$i.Name}}
}
$report | Export-CSV c:\GroupMembers.csv -NoType
The difference this time is that the output from our code is being saved in the $report variable. Once the report has been generated, the $report object is then exported to a CSV file that can be opened in Excel.
Read now
Unlock full access