I recently needed to install SharePoint in a scenario where I was installing in a LAB domain under while logged in to an account that was from a trusted domain. Note: ALL accounts for SharePoint where in the LAB domain. It appears that in this scenario,
the following does not work to validate the accounts
$currentDomain = "LDAP://" + ([ADSI]"").distinguishedName
To get around this, I added a new Helper function
# Func: GetLDAPDistingushedNameFromDomainName
# Desc: Return the correct LDAP distingushed name from the Friendly Domain Name
$myRootDirContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('domain', $friendlyDomainName)
$myRootDomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain([System.DirectoryServices.ActiveDirectory.DirectoryContext]$myRootDirContext)
and then used it like this
$domain, $userName = $user -split "\\"
$currentDomain = "LDAP://" + (GetLDAPDistingushedNameFromDomainName($domain))
Any interest in moving this into the main code branch?