Cmdlet to get AcceptMessagesOnlyFrom property for Distribution groups

Hishan 71 Reputation points

I guess this is a continuation of an age old question posted by ShayLevi in 2009 in the below post.

Someone going with the name "Guy Techie" asked a question about this command but never got answered. I would like to repeat his question here again because I have run into an issue with similar setting.

I've used your command:

Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select-object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",($_.AcceptMessagesOnlyFrom | foreach {Split-Path $_ -Leaf}) )}} | export-csv c:\DistList.csv

and works great, but it does not list security groups or it's members who are also in the "AcceptMessagesOnlyFrom" attribute. Is there a way to also list the security groups as well?

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,208 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,272 questions
0 comments No comments
{count} votes

Accepted answer
  1. Joyce Shen - MSFT 16,626 Reputation points

    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.

    3 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Vasil Michev 90,631 Reputation points MVP

    The cmdlet above will return data for Mail-enabled security groups too. "Pure" security groups are not relevant here.

  2. Limitless Technology 39,161 Reputation points

    Hi there,

    You may not have access to some parameters if they're not included in the permissions assigned to you.

    You can check this with help of powershell.
    Find the permissions required to run any Exchange cmdlet


    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments