From Terminal23wiki
function BuildLDAPString ($strLocation)
{
$strLDAPOUPath = ""
$strLocation = $strLocation.split("/")
foreach ($i in $strLocation)
{
$strLDAPOUPath = "ou=" + $i + "," + $strLDAPOUPath
}
$strLDAP = "LDAP://" + $strLDAPOUPath + "dc=YOURSUBDOMAIN,dc=YOURDOMAIN,dc=com"
return $strLDAP
}
function BuildLDAPObjectString ($strLDAPObjectName,$strLocation)
{
$strLDAPOUPath = ""
$strLocation = $strLocation.split("/")
foreach ($i in $strLocation)
{
$strLDAPOUPath = "ou=" + $i + "," + $strLDAPOUPath
}
$strLDAP = "LDAP://cn=" + $strLDAPObjectName + "," + $strLDAPOUPath + "dc=YOURSUBDOMAIN,dc=YOURDOMAIN,dc=com"
return $strLDAP
}