How to install Active Directory using PowerShell
1 min read · Updated 16 October 2021
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 @paramsVideo : How to install Active Directory using PowerShell
Related links
- Installation
How to install Active Directory via the graphical interface
First of four articles showcasing different methods for installing Active Directory
1 min read
- Installation
How to install Active Directory with PowerShell DSC
How to install Active Directory and create a domain with PowerShell DSC (Desired State Configuration)
3 min read
- Installation
How to install Active Directory using the dcpromo command
Second of four articles presenting different methods for installing Active Directory
2 min read
- Maintenance
Fix an Active Directory sign-on approval relationship error
How to fix a sign-on approval relationship error in Active Directory
2 min read
- Tips
How to create a multiboot USB key with the Ventoy tool
It's useful to have a multiboot USB stick containing operating system images or troubleshooting tools that you can boot from if you need to
1 min read
- Configuration
How to join an Active Directory domain using the netdom command
Join an Active Directory domain with the netdom command
1 min read