title: How to set Incoming email Active Directory container for new distribution groups using PowerShell
body: <p>In the Central Administration of SharePoint 2016, 'Incoming E-Mail Settings' page, I need to set the property for the field 'Active Directory container where new distribution groups and contacts will be created'.</p>
  
  <p>I cannot find using PowerShell the actual property to set the AD container. </p>
  
  <p>Anybody know how I can set it?</p>
  
  <p>Thanks.</p>
  
  <pre><code>        #Configure SP incoming mail settings
          $svcinstance = Get-SPServiceInstance | ? { $_.TypeName -eq 'Microsoft SharePoint Foundation Incoming E-Mail' }  
          $incomingMail = $svcinstance.Service  
  
          if ($incomingMail -ne $null) {  
              #Enable sites on this server to receive e-mail  
              $incomingMail.Enabled = $true  
  
              #Automatic Settings mode  
              $incomingMail.UseAutomaticSettings = $false  
  
              #Use the SharePoint Directory Management Service to create distribution groups  
              $incomingMail.UseDirectoryManagementService = $true
  
              #Accept messages from authenticated users only  
              $incomingMail.DLsRequireAuthenticatedSenders = $true  
  
              #Allow creation of distribution groups from SharePoint sites  
              $incomingMail.DistributionGroupsEnabled = $true  
  
              #SMTP mail server for incoming mail  
              $incomingMail.ServerAddress = $smtpServerDomainName  
  
              #E-mail server display address  
              $incomingMail.ServerDisplayAddress = $emailDisplayAddress  
  
              #E-mail drop folder  
              $incomingMail.DropFolder = $emailDropFolder 
  
              $incomingMail.Update();  
          }  
  </code></pre>