-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInstall-AD.ps1
50 lines (42 loc) · 2.03 KB
/
Install-AD.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
================================================================================================
AD Installer Script: InstallAD.ps1
Powershell script to automate the installation of active directory forest.
Author: Scarred Monk (@ScarredMonk)
================================================================================================
#>
<#
.Synopsis
Adds the required roles to install AD forest and then installs forest with the entered name.
.DESCRIPTION
The goal of AD Installer script is to automate the AD installation part using powershell.
.EXAMPLE
Import-Module .\ADInstaller.ps1; Invoke-ADInstaller -DomainName rootdse.org
#>
Write-Host ""
function DisplayInfo {
$info = 'Invoke-ADForest deployment script'
Write-Host $info -ForegroundColor "Yellow"
}
function InstallADRole {
Write-Host "[+] Installing required AD Roles and features." -ForegroundColor 'Green'
Install-windowsFeature AD-Domain-Services
Add-windowsfeature RSAT-ADDS
Import-Module ADDSDeployment
Write-Host "`n`nAD Roles and features are installed.`n`n" -ForegroundColor "Gray"
}
function ADforestInstall {
Write-Host "[+] Installing AD forest $DomainName" -ForegroundColor 'Green'
$DomainNetBiosName = $DomainName.split('.')[0]
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "C:\\Windows\\NTDS" -DomainMode "7" -DomainName $DomainName -DomainNetbiosName $DomainNetBiosName -ForestMode "7" -InstallDns:$true -LogPath "C:\\Windows\\NTDS" -NoRebootOnCompletion:$false -SysvolPath "C:\\Windows\\SYSVOL" -Force:$true -SkipPreChecks -SafeModeAdministratorPassword $pass -WarningAction silentlyContinue
Write-Host "`n`n$DomainName has been installed successfully. Domain controller will restart`n`n" -ForegroundColor 'Gray'
}
function Invoke-ADInstaller
{
Param
([Parameter(Mandatory=$true, Position=0)] [string] $DomainName)
$pass = Read-Host -Prompt "Set Safe Mode Administrator Password" -AsSecureString
DisplayInfo
InstallADRole
ADforestInstall
}