Exchange online : How to list the authorized senders of a distribution group (smart way)

Viewed 1672

I'm looking to list the authorized senders of a distribution group here's my code:

(Get-DistributionGroup -Identity "mydistributiongroup").AcceptMessagesOnlyFrom|get-mailcontact|Select-Object -Property DisplayName,Name,PrimarySmtpAddress

problem : there are exchange mailboxes in my list in addition to external mail

how to modify my code to take into account the mail exchange (get-mailbox instead of get-mail contact) in a smart way and fast

thank you

1 Answers
(Get-DistributionGroup -Identity "mydistributiongroup").AcceptMessagesOnlyFrom |
Get-Recipient |
Select-Object -Property DisplayName,Name,PrimarySmtpAddress

I believe this will do what you want.

Related