Hi @Hishan
We could refer to the introduction to the parameter in the official document:
The AcceptMessagesOnlyFrom parameter specifies who is allowed to send messages to this recipient. Messages from other senders are rejected. Valid values for this parameter are individual senders in your organization(mailboxes, mail users, and mail contacts).
However, The AcceptMessagesOnlyFromSendersOrMembers parameter specifies who is allowed to send messages to this recipient. Messages from other senders are rejected. Valid values for this parameter are individual senders and groups in your organization. Individual senders are mailboxes, mail users, and mail contacts. Groups are distribution groups, mail-enabled security groups, and dynamic distribution groups.
For example:
You could try the command like this to make it list all users and security groups:
Get-DistributionGroup -ResultSize Unlimited -filter {(AcceptMessagesOnlyFrom -ne $null) -or (AcceptMessagesOnlyFromDLMembers -ne $null) } | select-object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",($_.AcceptMessagesOnlyFromSendersOrMembers | foreach {Split-Path $_ -Leaf}) )}} | export-csv c:\DistList.csv
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.