Skip to content

Instantly share code, notes, and snippets.

@shanehoey
Last active January 21, 2023 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanehoey/45ca3d6bece55c9397047447f52b690f to your computer and use it in GitHub Desktop.
Save shanehoey/45ca3d6bece55c9397047447f52b690f to your computer and use it in GitHub Desktop.
New AD Forest

New AdForest

$servername =       "dc01"
$domainname =       "example.com"
$netbios    =       "example"
$ipaddress =        "192.168.10.248"
$prefixlenght =     "24"
$defaultgateway =   "192.168.10.254"
$ifindex =          (get-netadapter).ifindex

New-NetIPAddress -IPAddress $ipaddress -PrefixLength $prefixlenght -InterfaceIndex $ifindex -DefaultGateway $defaultgateway

rename-computer -newname $servername -force
restart-computer

Add-WindowsFeature "RSAT-AD-Tools" 
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools
restart-computer

Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "C:\Windows\NTDS" -DomainMode "Win2012" ` 
-DomainName $domainname -DomainNetbiosName $netbiosName -ForestMode "Win2016" -InstallDns:$true ` 
-LogPath "C:\Windows\NTDS" -NoRebootOnCompletion:$false -SysvolPath "C:\Windows\SYSVOL" -Force:$true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment