Domain Name Format is Invalid

I have been assigned to a project to integrate another facility’s computers into our domain. I’m trying to script the domain join process but I keep receiving an error indicating the format of the specified domain name is invalid. If I go through the GUI it accepts the domain name just fine and everything is right as rain. The code I’m attempting to us is as follows:

Add-Computer -DomainName -Credential $OSFCred -Passthru

I’ve surfed around a bit and a few sites suggested it could be a DNS issue, and that the primary DNS had to be pointing to the DC for the domain I wish to join, but making that change had no impact on resolving the error even after clearing the local dns cache.

Please advise?

Does it work if you use the short name (Intranet) versus the FQDN? It might just be how the cmdlet is resolving the domain.

It does not. If I replace the fqdn with “intranet” I get an error indicating the domain controller for the specified domain name could not be reached

It’s definitely name resolution. I wouldn’t say changing the DNS, necessarily, but make sure the existing DNS server knows how to reach the other domain’s DCs. When you use the GUI, a whole different set of protocols can end up getting involved - it does more under the hood work for you. An alternate would be to temporarily, via script, hack the hosts file on the machine so it can find the remote domain. Or hack lmhosts so it can find the domain by its NetBIOS (short) name.

Or, alternately, use Netdom.exe instead of Add-Computer.