Skip to content

Instantly share code, notes, and snippets.

@nivleshc
Created May 26, 2018 13:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nivleshc/eb404932de872c0bfa49c7b05ca2c3f3 to your computer and use it in GitHub Desktop.
Save nivleshc/eb404932de872c0bfa49c7b05ca2c3f3 to your computer and use it in GitHub Desktop.
Configure-ADForest.ps1 PowerShell script used by CloudFormation template to deploy Active Directory Domain Services
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$DomainName,
[Parameter(Mandatory=$true)]
[string]$DomainNetBiosName,
[Parameter(Mandatory=$true)]
[string]$DomainMode,
[Parameter(Mandatory=$true)]
[string]$ForestMode,
[Parameter(Mandatory=$true)]
[string]$SafeModeAdministratorPassword
)
# Create New Forest, add Domain Controller
Import-Module ADDSDeployment
#Convert the SafeModeAdministratorPassword to a secureString
$SecuredSafeModeAdministratorPassword = ConvertTo-SecureString -String $SafeModeAdministratorPassword -AsPlainText -Force
Install-ADDSForest -CreateDnsDelegation:$false `
-DomainName $DomainName `
-DomainNetbiosName $DomainNetbiosName `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode $DomainMode `
-ForestMode $ForestMode `
-SafeModeAdministratorPassword $SecuredSafeModeAdministratorPassword `
-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