exmachina
exmachina

Reputation: 25

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

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

Upvotes: 2

Views: 8230

Answers (1)

Mark Mascolino
Mark Mascolino

Reputation: 2292

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

I believe this will do what you want.

Upvotes: 4

Related Questions