Adding a machine to a domain fails with internal error

witchkinkofangmar 1 Reputation point
2022-04-07T15:37:28.25+00:00

I've enabled SMBv1 and completed updates first as troubleshooting but I still get the error.
The error I get is:

Add-Computer: Computer "server2019' failed to join domain 'dev.domain.com' from its current workgroup 'WORKGROUP' with following error message: An internal error occurred.
At line:1 char:1
Add-Computer -DomainName dev.domain.com -OUPath "OU=$OU,dc=dev,dc=domain,dc=com" ...

  • CategorvInfo :Operation5topped: (server2019:5tring) [Add-Computer]
    . InvalidoperationException
  • FullvOualifiedErrorId:FailToJoinDomainFromworkgroup,Microsoft.PowerShell.Commands.AddComputerCommand

Here is the part of my script that does the join:

param (
    [String]$OU,
    [PSCredential]$Credential
    )

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"


if ([Environment]::UserInteractive) {
    if (!$OU) { $OU = Read-Host "Enter Resource Pool Name (exactly as appears in vCenter inventory)" }
    if (!$Credential) { $Credential = Get-Credential -Message "Enter dev domain credentials" }
}

# Add Computer to Dev domain

try {
    Add-Computer -DomainName dev.domain.com -OUPath "OU=$OU,dc=dev,dc=domain,dc=com" -ErrorAction stop -Credential $Credential
    }
catch {
    Write-Warning "Failed to join to domain."
        Read-Host -Prompt "Press Enter to exit"
    Throw $_
    }
Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,544 questions
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,418 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,434 questions
0 comments No comments
{count} votes