How to install Active Directory using Powershell

To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!

Third of four articles presenting different methods for installing Active Directory:
Installing Microsoft Active Directory via the GUI (server 2012, 2012r2, 2016, 2019, 2022)
- Install Microsoft Active Directory via the dcpromo  command(server 2003, 2008, 2008r2, 2012, 2012r2, 2016, 2019, 2022)
- Install Microsoft Active Directory via Powershell (server 2012, 2012r2, 2016, 2019, 2022)
- Installing Microsoft Active Directory via Powershell DSC (server 2016, 2019, 2022)

Powershell code - Active Directory installation

# Installing the role.
Add-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
# Configuring the role
$domaine = 'domaine.tld'
$DsrmPass = 'P@ssword'
Import-Module ADDSDeployment
$params = @{
CreateDnsDelegation = $false
# 2 ou Win2003, 3 ou Win2008, 4 ou Win2008R2, 5 ou Win2012, 6 ou Win2012R2,7 ou WinThreshold
DomainMode = 'Win2012r2'
DomainName = $domaine
DomainNetbiosName = $domaine.split('.')[0]
# 2 ou Win2003, 3 ou Win2008, 4 ou Win2008R2, 5 ou Win2012, 6 ou Win2012R2,7 ou WinThreshold
ForestMode = 'Win2012r2'
InstallDns = $true
DatabasePath = 'C:\Windows\NTDS'
LogPath = 'C:\Windows\NTDS'
SysvolPath = 'C:\Windows\SYSVOL'
NoRebootOnCompletion = $false
Force = $true
SafeModeAdministratorPassword = (ConvertTo-SecureString -AsPlainText -Force -String $DsrmPass)
}
Install-ADDSForest @params

Video : How to install Active Directory using Powershell

Related links