'Install-ADDSDomainController Hangs

I am using the following code to promote DCs. I get several warning as expected and no errors however it hangs after the warning "A delegation for this DNS server cannot be created because the authoritive parent zone cannot be found.

Powershell appears to be trying these 2 options "Determining replication source DC" and "Configuring the local computer to host Active Directory Domain Services" as seen in this image. Powershell Warnings and Information

 Write-Host "`nPromoting Server to a DC..."
        $Error.Clear()     
    
        #Get Domain name
        $domain = $env:USERDNSDOMAIN
        
        #Promote DC
 #Promote DC
        try {
            Install-ADDSDomainController `
                -NoGlobalCatalog:$false `
                -CreateDnsDelegation:$false `
                -Credential (Get-Credential) `
                -CriticalReplicationOnly:$false `
                -DatabasePath "C:\Windows\NTDS" `
                -DomainName $domain `
                -InstallDns:$true `
                -LogPath "C:\Windows\NTDS" `
                -NoRebootOnCompletion:$false `
                -SysvolPath "C:\Windows\SYSVOL" `
                -Force:$true
        }
        catch { #Not all errors are getting caught here
            Write-Host "`n`nThere was an error promting DC!" -ForegroundColor Red
            Write-Host "`nReview error below and rerun script:" -ForegroundColor Yellow
            Read-Host "Press any key to continue..."
            Write-Host "`n $error"
            Exit
        }


Solution 1:[1]

The problem was due to the login name.

It requires domain\username when entering the credentials.

If you do not include the domain will start and perform some of the promotion tasks, but eventually will hang.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aaron Krytus