Added Install-ADDSForest to RFM.

This commit is contained in:
Michael Grafnetter 2019-01-11 23:10:03 +01:00
parent 09c7928c45
commit b566a075fc
2 changed files with 84 additions and 64 deletions

View File

@ -6,8 +6,9 @@ Restores the {DCName} domain controller from ntds.dit.
This script should only be executed on a freshly installed {OSName}. Use at your own risk
The DSInternals PowerShell module must be installed for all users on the target server.
.AUTHOR
Michael Grafnetter
Author: Michael Grafnetter
#>
#Requires -Version 3 -Modules DSInternals -RunAsAdministrator
@ -36,6 +37,23 @@ $initTask = Register-ScheduledJob -Name DSInternals-RFM-Initializer -ScriptBlock
# Advice: It is recommenced to change the DSRM password after DC promotion.
dcpromo.exe /unattend /ReplicaOrNewDomain:Domain /NewDomain:Forest /NewDomainDNSName:"{DomainName}" /DomainNetBiosName:"{NetBIOSDomainName}" /DomainLevel:{DomainMode} /ForestLevel:{ForestMode} '/SafeModeAdminPassword:"{DSRMPassword}"' /DatabasePath:"{TargetDBDirPath}" /LogPath:"{TargetLogDirPath}" /SysVolPath:"{TargetSysvolPath}" /AllowDomainReinstall:Yes /CreateDNSDelegation:No /DNSOnNetwork:No /InstallDNS:Yes /RebootOnCompletion:No
Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\10 -Name ConfigurationStatus -Value 2 -Force
<# Alternative approach for Winows Server 2012+
Install-WindowsFeature -Name AD-Domain-Services
Install-ADDSForest -DomainName '{DomainName}' `
-DomainNetbiosName '{NetBIOSDomainName}' `
-ForestMode {ForestModeString} `
-DomainMode {DomainModeString} `
-DatabasePath "{TargetDBDirPath}" `
-LogPath "{TargetLogDirPath}" `
-SysvolPath "{TargetSysvolPath}" `
-InstallDns `
-CreateDnsDelegation:$false `
-NoDnsOnNetwork `
-SafeModeAdministratorPassword (ConvertTo-SecureString -String '{DSRMPassword}' -AsPlainText -Force)`
-NoRebootOnCompletion `
-Force
#>
}
# Reboot the computer into the Directory Services Restore Mode.

View File

@ -94,6 +94,8 @@
Replace("{DomainSid}", dc.DomainSid.ToString()).
Replace("{DomainMode}", ((int)dc.DomainMode).ToString()).
Replace("{ForestMode}", ((int)dc.ForestMode).ToString()).
Replace("{DomainModeString}", (dc.DomainMode).ToString()).
Replace("{ForestModeString}", (dc.ForestMode).ToString()).
Replace("{OSName}", dc.OSName).
Replace("{OldBootKey}", this.BootKey.ToHex()).
Replace("{SourceDBPath}", this.DirectoryContext.DSADatabaseFile).