Skip navigation
PowerShell to create domains

PowerShell to create domains

Q. What is simple PowerShell to quickly create a new domain?

A. The PowerShell below will create a new domain and forest based on the values configured in the variables. It will make itself a DNS server but will not alter its local DNS configuration. if you want the local DNS updated remove the -SkipAutoConfigureDNS parameter in the example below.

Import-Module "Servermanager" #For Add-WindowsFeature
Add-WindowsFeature AD-Domain-Services, DNS -IncludeManagementTools

$netbiosname = 'POCDom'
$fqdomname = 'pocdom.local'
$NTDSPath = 'e:\ntds'
$NTDSLogPath = 'e:\ntdslogs'
$SYSVOLPath = 'e:\sysvol'

$SafePassPlain = 'Pa55word'
$SafePass = ConvertTo-SecureString -string $SafePassPlain `
    -AsPlainText -force

Install-ADDSForest -DomainName $fqdomname -DomainNetBIOSName $netbiosname `
    -SafemodeAdministratorPassword $SafePass -SkipAutoConfigureDNS -SkipPreChecks `
    -InstallDNS:$true -SYSVOLPath $SysvolPath -DatabasePath $NTDSPath -LogPath $NTDSLogpath `
    -Force

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish