{"id":196093,"date":"2022-08-12T10:50:46","date_gmt":"2022-08-12T15:50:46","guid":{"rendered":"https:\/\/itblog.ldlnet.net\/?p=196093"},"modified":"2024-05-10T08:38:04","modified_gmt":"2024-05-10T13:38:04","slug":"allow-an-m365-user-to-send-to-multiple-restricted-groups-and-dynamic-dls","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2022\/08\/12\/allow-an-m365-user-to-send-to-multiple-restricted-groups-and-dynamic-dls\/","title":{"rendered":"Allow an M365 User to send to multiple Restricted  Groups and Dynamic DLs"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Scenario<\/h3>\n\n\n\n<p>You have a new Executive or top level user that needs to be able to send emails to all distribution lists in the M365 Org, INCLUDING Restricted ones where only certain senders can communicate with the DL or Group. Not all groups are restricted and you need to only add them to the restricted groups and DLs. To know what groups have a restriction, you look for the<strong><em> AcceptMessagesOnlyFromSendersorMembers<\/em><\/strong> parameter when you get the DL properties.<\/p>\n\n\n\n<p>I have created the following PowerShell commands that will allow you to accomplish this task successfully.<\/p>\n\n\n\n<p>After connecting to <strong>Exchange Online PowerShell<\/strong>, review what DL and Dynamic DLs are restricted:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Get a list of Restricted DLs\">Get-DistributionGroup | ? {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select-Object Identity<\/pre>\n\n\n\n<p>Do the same for Dynamic DLs:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Get a list of Restricted Dynamic DLs\">Get-DynamicDistributionGroup | ? {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select-Object Identity<\/pre>\n\n\n\n<p>Once those DLs are verified, we want to get the UPN of the user we want to add to the list. For this case we can use <strong><em>mynewuser01@ldlnet.net<\/em><\/strong> for this purpose.<\/p>\n\n\n\n<p>In PowerShell, we want to pipe: &#8216;|&#8217;  multiple commands together so that we can accomplish the task with the list we just generated. We want to user the <strong>where &#8216;?&#8217;<\/strong> parameter to filter the groups by the attribute, and then user the <strong>foreach &#8216;%&#8217;<\/strong> statement so that we can add the user to each DL in the list. We are also going to use the array parameter <strong>&#8216;@{function=&#8221;data1&#8243;,&#8221;data2&#8243;,etc&#8230;}&#8217;<\/strong> so that we can add multiple users if necessary for this function of <strong>add<\/strong> to add the user(s). If you wanted to <strong>remove<\/strong> the users, then change the add function to remove in the statement.<\/p>\n\n\n\n<p>Here is the cmdlet:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Add user to send to Restricted DLs\">Get-DistributionGroup | ? {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select-Object Identity | % {Set-DistributionGroup $_.Identity -AcceptMessagesOnlyFromSendersOrMembers @{add=\"mynewuser01@ldlnet.net\"}}<\/pre>\n\n\n\n<p>Do the same for Dynamic DLs:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Ad user to send to Restricted Dynamic DLs\">Get-DynamicDistributionGroup | ? {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select-Object Identity | % {Set-DynamicDistributionGroup $_.Identity -AcceptMessagesOnlyFromSendersOrMembers @{add=\"mynewuser01@ldlnet.net\"}}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>Exchange Online PowerShell provides many good tools to filter and complete tasks that might seem arduous when manually done in the GUI portal. <\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\">THANKS FOR READING!<\/h2>\n\n\n\n<p><strong><em>REFERENCES:<\/em><\/strong><br><a href=\"https:\/\/answers.microsoft.com\/en-us\/msoffice\/forum\/all\/how-to-addremove-allow-sender-of-distribution\/b899206d-ba53-4ff2-89c7-931bf1f4666d\">How to add\/remove allow sender of distribution group with &#8211; Microsoft Community<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About Lance Lingerfelt<\/h2>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:22% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"412\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2024\/03\/ProfLDL1.jpg\" alt=\"Lance Lingerfelt Profile Photo\" class=\"wp-image-196223 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-small-font-size\">Lance Lingerfelt is an M365 Specialist and Evangelist with over 20 years of experience in the Information Technology field. Having worked in enterprise environments to small businesses, he is able to adapt and provide the best IT Training and Consultation possible. With a focus on AI, the M365 Stack, and Healthcare, he continues to give back to the community with training, public speaking events, and this blog.<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Scenario You have a new Executive or top level user that needs to be able to send emails to all distribution lists<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2022\/08\/12\/allow-an-m365-user-to-send-to-multiple-restricted-groups-and-dynamic-dls\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":147,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[267,4,2,265,194,3],"tags":[78,153,8,13],"class_list":["post-196093","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-active-directory","category-exchange","category-general","category-microsoft365","category-office365","category-powershell","tag-exchange-onlilne","tag-permissions","tag-powershell","tag-script","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/196093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=196093"}],"version-history":[{"count":8,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/196093\/revisions"}],"predecessor-version":[{"id":196312,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/196093\/revisions\/196312"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/147"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=196093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=196093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=196093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}