0

I am using SharePoint 2016 where two way trust is enabled. Users are connecting from Contoso1 while SharePoint is running on Contoso2.

I was using the following domains in people picker:

Contoso1
Contoso2

By mistake I added Contoso1 again so now when I check $wa.peoplepickersettings.searchactivedirectorydomains it is showing me three domains:

Contoso1
Contoso2
Contoso1

I am trying to remove Contoso2 but always get false by the Remove function below. How can I remove a domain from People Picker?

$wa = get-spwebapplication https://theWebApp.contoso.com
$searchad = $wa.peoplepickersettings.searchactivedirectorydomains
$newdomain1 = new-object Microsoft.SharePoint.Administration.sppeoplepickersearchactivedirectorydomain
$newdomain1.domainname = "contoso2.com"
$newdomain1.Isforest = $true
$searchad.remove($newdomain1)
$wa.update()

Additionally, how can I also remove the extra Contoso1?

1
  • I used Stsadm setproperty to configure People Picker in SP 2013 Farm. I think, it would work for SP 2016 as well. See this MS Article Commented Jun 11 at 15:20

1 Answer 1

1

With your code, you try to remove an instance you never added to the collection!

The easy way is to clear the configuration and add only the forest you want:

$wa = Get-SPWebApplication https://theWebApp.contoso.com
$searchad = $wa.PeoplePickerSettings.SearchActiveDirectoryDomains
$searchad.Clear()

$newdomain1 = New-Object Microsoft.SharePoint.Administration.SPPeoplePickerSearchActiveDirectoryDomain
$newdomain1.DomainName = "contoso1.com"
$newdomain1.ShortName = "contoso1"
$newdomain1.IsForest = $True
$searchad.Add($newdomain1)
$wa.Update()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.