PowerShell to create domains

Find out how to create a domain with PowerShell.

John Savill

August 20, 2016

1 Min Read
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-WindowsFeatureAdd-WindowsFeature AD-Domain-Services, DNS -IncludeManagementTools$netbiosname = 'POCDom'$fqdomname = 'pocdom.local'$NTDSPath = 'e:tds'$NTDSLogPath = 'e:tdslogs'$SYSVOLPath = 'e:sysvol'$SafePassPlain = 'Pa55word'$SafePass = ConvertTo-SecureString -string $SafePassPlain `    -AsPlainText -forceInstall-ADDSForest -DomainName $fqdomname -DomainNetBIOSName $netbiosname `    -SafemodeAdministratorPassword $SafePass -SkipAutoConfigureDNS -SkipPreChecks `    -InstallDNS:$true -SYSVOLPath $SysvolPath -DatabasePath $NTDSPath -LogPath $NTDSLogpath `    -Force

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like