$domain_trust = "mycompany.local"
$pp_user_in_trusted_domain = "pp_username"
$pp_pass_in_trusted_domain = "pp_password"
$pp_password = "peoplepickerpassword"
$computer = Get-WmiObject -Class Win32_ComputerSystem
$domain_local = $computer.domain
stsadm.exe -o setapppassword -password $pp_password
stsadm -o setproperty -pn "peoplepicker-onlysearchwithinsitecollection" -propertyvalue No
$all_webapps = Get-SPWebApplication -IncludeCentralAdministration
foreach ($webapp in $all_webapps)
{
stsadm -o setproperty -pn "peoplepicker-onlysearchwithinsitecollection" -propertyvalue No -url $webapp.url
stsadm.exe -o setproperty -url $webapp.url -pn "peoplepicker-searchadforests" -pv "domain:$domain_local;domain:$domain_trust,$pp_user_in_trusted_domain@$domain_trust,$pp_pass_in_trusted_domain"
}