Powershell script – Join domain
This script helps to join the machine to the domain local and if you want to do it remotely you can combined this script using invoke-command
$credential = New-Object System.Management.Automation.PsCredential("coex\administrator", (ConvertTo-SecureString "P@ssw0rd <mailto:P@ssw0rd>" -AsPlainText -Force))
Add-Computer -DomainName "coex.com" -Credential $credential -passthru
restart-computer