如何使用PowerShell为新通讯组设置传入电子邮件Active Directory容器

如何使用PowerShell为新通讯组设置传入电子邮件Active Directory容器,powershell,sharepoint,sharepoint-2016,Powershell,Sharepoint,Sharepoint 2016,在SharePoint 2016管理中心的“传入电子邮件设置”页面中,我需要设置字段“将在其中创建新通讯组和联系人的Active Directory容器”的属性 我无法找到使用PowerShell设置AD容器的实际属性 有人知道我怎么设置吗 谢谢 #Configure SP incoming mail settings $svcinstance = Get-SPServiceInstance | ? { $_.TypeName -eq 'Microsoft Sha

在SharePoint 2016管理中心的“传入电子邮件设置”页面中,我需要设置字段“将在其中创建新通讯组和联系人的Active Directory容器”的属性

我无法找到使用PowerShell设置AD容器的实际属性

有人知道我怎么设置吗

谢谢

        #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();  
        }  

了解如何实现这一点:

#Active Directory container where new distribution groups and contacts will be created    
$webApp = Get-SPWebApplication -IncludeCentralAdministration | Where {$_.DisplayName -eq "SharePoint Central Administration v4"}
$site = $webApp.Sites[0]
$web = $site.RootWeb

if($web.AllProperties['EmailWebService_ADContainer']){
    $web.AllProperties.Remove('EmailWebService_ADContainer');   
    $web.Properties['EmailWebService_ADContainer'] = $null;
    $web.Update();
    $web.Properties.Update();
}

$web.AllProperties.Add('EmailWebService_ADContainer',$activeDirectoryOU) 
$web.Update() 
$web.Dispose();
$site.Dispose();
参考: