HI Pasha.
Greetings.
Thank you for raising your concern in this community.
If you have a c:\scripts folder
Place this script and run it if you don’t have one, please create it.
Make sure that the CSV file is edited accordingly.
Make sure to check if the file is unblocked to prevent any errors when running the script.
CSV file export path
$Csvfile = "C:\scripts\ExportDGs.csv"
Get all distribution groups
$Groups = Get-DistributionGroup -ResultSize Unlimited
Loop through distribution groups
$Groups | ForEach-Object {
$Group = $_.Name
$DisplayName = $_.DisplayName
$PrimarySmtpAddress = $_.PrimarySmtpAddress
$GroupType = $_.GroupType
$RecipientType = $_.RecipientType
$Members = Get-DistributionGroupMember $group
$ManagedBy = $_.ManagedBy
$Alias = $_.Alias
$HiddenFromAddressLists = $_.HiddenFromAddressListsEnabled
$MemberJoinRestriction = $_.MemberJoinRestriction
$MemberDepartRestriction = $_.MemberDepartRestriction
$RequireSenderAuthenticationEnabled = $_.RequireSenderAuthenticationEnabled
$AcceptMessagesOnlyFrom = $_.AcceptMessagesOnlyFrom
$GrantSendOnBehalfTo = $_.GrantSendOnBehalfTo
Create objects
[PSCustomObject]@{
Name = $Group
DisplayName = $DisplayName
PrimarySmtpAddress = $PrimarySmtpAddress
Alias = $Alias
GroupType = $GroupType
RecipientType = $RecipientType
Members = ($Members.Name -join ',')
MembersPrimarySmtpAddress = ($Members.PrimarySmtpAddress -join ',')
ManagedBy = $ManagedBy.Name
HiddenFromAddressLists = $HiddenFromAddressLists
MemberJoinRestriction = $MemberJoinRestriction
MemberDepartRestriction = $MemberDepartRestriction
RequireSenderAuthenticationEnabled = $RequireSenderAuthenticationEnabled
AcceptMessagesOnlyFrom = ($AcceptMessagesOnlyFrom.Name -join ',')
GrantSendOnBehalfTo = $GrantSendOnBehalfTo.Name
}
Export report to CSV file
} | Export-CSV -Path $Csvfile -NoTypeInformation -Encoding UTF8 #-Delimiter ";"
I will be waiting for your feedback.
Regards,
Mac