Set-ExecutionPolicy -ExecutionPolicy “Unrestricted” -Force

Write-Host “”

Write-Host “========================================================”

Write-Host “People Picker – Adding Trusts……”

Write-Host “- Set an encryption key for use with a one-way trust ”

Write-Host “- Enable cross-forest or cross-domain queries when you use a one-way trust”

Write-Host “- Set an encryption key for use with a one-way trust ”

Write-Host “- Set an encryption key for use with a one-way trust ”

Write-Host “https://technet.microsoft.com/en-gb/library/gg602075.aspx”

Write-Host “========================================================”

Write-Host “”

$URLList = @()

$URLList += “http://spsite”

$URLList += “http://spsite:<Central Admin Port>”

#Allows to use SharePoint cmdlets from inside the Windows PowerShell command window

If ((Get-PsSnapin |?{$_.Name -eq “Microsoft.SharePoint.PowerShell”})-eq $null)

{

Add-PsSnapin Microsoft.SharePoint.PowerShell | Out-Null

}

try

{

Write-Host “- Updating encryption key”

stsadm -o setapppassword -password <passphase>

foreach ($URL in $URLList)

{

Write-Host “- Enable cross-forest or cross-domain queries for” $URL

STSADM -o setproperty -pn peoplepicker-searchadforests -pv “domain:<ad.domain.com,AD\xxx_SP_Profile,<service account password>;forest:ad.forestdomain.com,AD\xxx_SP_Profile,<service account password>” -url $URL

}

}

catch { Write-Output $_ }