This is the latest version of my Offline Domain Join script for ConnectWise Automate. This script will join a computer to a domain with no network connection to the domain controller. Automate finds the "Domain naming master" server for the client, generates a file, transfers the file over to the target agent, then uses it to do a domain join. The script can also work when a computer is in the same network as the domain controller. We use it for all domain joining.
If a client has multiple domain naming masters the script will automatically fail. If the target computer is on a domain or a workgroup other than "WORKGROUP", it will automatically fail. If the target computer is Azure AD joined, it will automatically fail.
Once joined, domain credentials wont work until the target computer can communicate a domain controller. If someone has a trick for that, I'd love to hear it.