Cmdlet to get AcceptMessagesOnlyFrom property for Distribution groups

Hishan 71 Reputation points
2021-12-06T10:51:41.937+00:00

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

https://social.msdn.microsoft.com/Forums/en-US/6b5fbd76-8c9a-4d41-b291-9496ba9626e0/cmdlet-to-get-acceptmessagesonlyfrom-property-for-distribution-groups?forum=ITCG

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
    2021-12-07T02:51:15.463+00:00

    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:
    155417-image.png

    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
    2021-12-06T12:42:08.3+00:00

    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
    2021-12-09T08:48:33.39+00:00

    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
    https://learn.microsoft.com/en-us/powershell/exchange/find-exchange-cmdlet-permissions?view=exchange-ps

    ------------------------------------------------------------------------------------------------------------------------------------------------------

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

    0 comments No comments