Get-DistributionGroup
Exchange Online: Lists all distribution groups
#Requires -Version 5.1
Process {
try {
$groups = Get-DistributionGroup -ErrorAction Stop | Select-Object *
if ($null -eq $groups -or $groups.Count -eq 0) {
Write-Output "No distribution groups found"
return
}
foreach ($g in $groups) {
$g | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force
}
}
catch { throw }
}This script has no configurable parameters.