Error when trying to run DCPROMO on a Windows 2019 Server:

---------------------------
Active Directory Domain Services Installer
---------------------------
The Active Directory Domain Services Installation Wizard is relocated in Server Manager. For more information, see https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-
---------------------------
OK
---------------------------

Use RSAT & AD-Domain-Services Modules to Promote a Server as DC

# Set variables
$domain=$env:USERDNSDOMAIN
$domainAdminMember=$env:username
$cred=(Get-Credential "$domain\$domainAdminMember")

# Install DFS
Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con

# Install ActiveDirectory module
if(!(import-module activedirectory -ea ignore)){
    try{
        install-module activedirectory -force -ea Stop
    }catch{
        Import-Module ServerManager
        Add-WindowsFeature -Name "RSAT-AD-PowerShell" -IncludeAllSubFeature        
    }
}

# Errors when trying to install RSAT
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'activedirectory'. Try Get-PSRepository to see all available registered
module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PackageSource -Name 'nuget.org' -NewLocation 'https://www.nuget.org/api/v2/' -Trusted

# DCPromo & Install DNS Server
Dism.exe /online /enable-feature /featurename:DNS-Server-Full-Role
install-windowsfeature dns -includemanagementtools
if(!(Import-Module ADDSDeployment -ea ignore)){
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
Import-Module ADDSDeployment
}
Install-ADDSDomainController -InstallDns -Credential $cred -DomainName $domain -Force

# Error when AD-Domain-Services feature was not installed
Install-ADDSDomainController : The term 'Install-ADDSDomainController' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Install-ADDSDomainController -InstallDns -Credential $cred -DomainNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-ADDSDomainController:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Sample Output:

Issue: Windows Version 1709 is missing DNS Management Tools

Resolution:

If you have a Windows Server 2016 (not insider) machine on your network, or another Windows 10 with the WS2016 (not insider) RSAT tools installed, you need to copy four files from it to your Windows 10 after installing RSAT 16279. system32: dnsmgmt.msc and dnsmgr.dll system32\en-us: dnsmgmt.msc and DNSmgr.dll.mui (or slightly fewer keystrokes if you are using the command prompt to do it, copy dnsmg. in both system32 and system32\en-us folders) Then run this command as admin: regsvr32 c:\windows\system32\dnsmgr.dll

Source: https://techcommunity.microsoft.com/t5/windows-server-insiders/rsat-missing-dns-server-tools/m-p/113280/page/3