Connect-ExchangeOnlineGet-DynamicDistributionGroup | Select-Object Name,PrimarySmtpAddress(Get-DynamicDistributionGroup 'Group Name').RecipientFilterSet-DynamicDistributionGroup command — it replaces the whole filter, not just part of it.Quick add common requirements:
“Contains / starts with / ends with” add the * wildcards for you. Values with apostrophes are escaped automatically.
Nothing in the batch yet — build or edit a group, then add it. Commands pile up here so you can run them all in one shot.
Install-Module ExchangeOnlineManagement, then Connect-ExchangeOnline.Connect-ExchangeOnline
$report = @()
$report += foreach ($g in Get-DynamicDistributionGroup -ResultSize Unlimited) {
$members = @(Get-Recipient -RecipientPreviewFilter $g.RecipientFilter -ResultSize Unlimited |
Select-Object DisplayName,
@{n='PrimarySmtpAddress';e={"$($_.PrimarySmtpAddress)"}},
@{n='RecipientTypeDetails';e={"$($_.RecipientTypeDetails)"}})
[pscustomobject]@{
Type = 'Dynamic'
Name = $g.Name
Email = "$($g.PrimarySmtpAddress)"
Filter = "$($g.RecipientFilter)"
Members = $members
}
}
$report += foreach ($g in Get-DistributionGroup -ResultSize Unlimited) {
$members = @(Get-DistributionGroupMember -Identity "$($g.Guid)" -ResultSize Unlimited |
Select-Object DisplayName,
@{n='PrimarySmtpAddress';e={"$($_.PrimarySmtpAddress)"}},
@{n='RecipientTypeDetails';e={"$($_.RecipientTypeDetails)"}})
[pscustomobject]@{
Type = 'Static'
Name = $g.Name
Email = "$($g.PrimarySmtpAddress)"
Filter = ''
Members = $members
}
}
ConvertTo-Json -InputObject @($report) -Depth 5 -Compress | Set-Clipboard
Write-Host "Done - the report data is on your clipboard. Paste it into the builder page."