#requires -RunAsAdministrator # COMPUCARE IT | ACTIVE DIRECTORY # 01 - Install AD DS and create a NEW forest # REVIEW ALL SETTINGS BEFORE RUNNING. This promotes the server and restarts it. $ErrorActionPreference = 'Stop' $DomainName = 'ad.example.com' # Replace with a subdomain of a DNS domain your organization owns $NetBIOSName = 'ORG' $DatabasePath = 'C:\Windows\NTDS' $LogPath = 'C:\Windows\NTDS' $SysvolPath = 'C:\Windows\SYSVOL' if ($DomainName -eq 'ad.example.com') { throw 'Replace the example DomainName with your approved AD DNS name before running.' } if ((Get-CimInstance Win32_ComputerSystem).DomainRole -ge 4) { throw 'This server is already a domain controller. Do not run forest creation.' } if (-not (Get-Module -ListAvailable -Name ADDSDeployment)) { Install-WindowsFeature AD-Domain-Services,DNS -IncludeManagementTools } else { Install-WindowsFeature AD-Domain-Services,DNS -IncludeManagementTools } $DSRMPassword = Read-Host 'Enter a strong DSRM recovery password' -AsSecureString Install-ADDSForest ` -DomainName $DomainName ` -DomainNetbiosName $NetBIOSName ` -InstallDNS ` -DatabasePath $DatabasePath ` -LogPath $LogPath ` -SysvolPath $SysvolPath ` -SafeModeAdministratorPassword $DSRMPassword ` -CreateDnsDelegation:$false ` -Force