Mark Marquez

IT & Automation Specialist | Cybersecurity | Data-Engineering Enthusiast

Automating Active Directory Domain Controller Provisioning for MSPs

Active Directory Domain Controller Provisioning

Automating Active Directory Domain Controller Provisioning for MSPs

In modern IT environments, especially for Managed Service Providers (MSPs), efficiency, consistency, and security are paramount. Setting up an Active Directory Domain Controller (DC) is a foundational task that, when done manually, can be time-consuming and prone to human error. To address this, I developed a set of PowerShell scripts that fully automate the provisioning of an Active Directory Domain Controller on Windows Server 2025. This project, hosted on GitHub, streamlines the initial setup of a new AD forest and promotes a server to a DC following best practices tailored for MSPs.

Project Overview

This project focuses exclusively on the provisioning phase of an Active Directory Domain Controller—automating the initial setup process. Tasks such as configuration (e.g., adding users or Group Policy Objects) and ongoing management (e.g., monitoring or backups) are outside the scope of this repository and will be addressed in future projects as part of a broader network virtualization initiative.

The automation covers everything from system preparation and prerequisite validation to network configuration, role installation, DC promotion, and post-configuration security hardening. By automating these steps, the project ensures that MSPs can deploy Domain Controllers quickly, consistently, and securely across multiple client environments.

ADDC Setup Verification

Below is a screenshot verifying the successful setup of the ADDC (ADDC01-msp) with the msp.local domain:

ADDC Setup Screenshot

The Automation Process: From Manual to Automated

Manually provisioning a Domain Controller involves several critical steps, each of which can introduce variability or errors if not handled carefully. My scripts automate these steps, ensuring a smooth and error-free process. Here’s how the automation handles each stage:

  1. System Preparation
    • Manual Task: Install Windows updates and reboot to ensure the server is up to date.
    • Automation: The optional 00-Install-Updates.ps1 script checks for updates, installs them, and reboots if necessary, eliminating the need for manual intervention.
  2. Prerequisite Validation
    • Manual Task: Verify the OS version, administrative privileges, and sufficient disk space.
    • Automation: 01-Check-Prerequisites.ps1 performs these checks automatically and provides clear error messages if any conditions are not met, preventing issues later in the process.
  3. Network Configuration
    • Manual Task: Set a static IP address (e.g., 192.168.0.10), configure DNS to an external provider (e.g., 8.8.8.8), and ensure network connectivity.
    • Automation: 02-Set-StaticIP.ps1 detects the active network adapter, assigns the static IP, sets Google DNS, and validates connectivity—all without user input.
  4. AD DS Role Installation
    • Manual Task: Install the Active Directory Domain Services (AD DS) role and management tools via Server Manager or PowerShell.
    • Automation: 03-Install-ADDSRole.ps1 silently installs the AD DS role and tools while logging progress for transparency.
  5. DC Promotion
    • Manual Task: Promote the server to a Domain Controller, create a new forest (e.g., msp.local), set a Directory Services Restore Mode (DSRM) password, and reboot.
    • Automation: 04-Promote-DomainController.ps1 handles the promotion, securely manages the DSRM password, creates the forest, and triggers a reboot in a single step.
  6. Post-Configuration
    • Manual Task: Update DNS to point to the DC itself (e.g., 192.168.0.10), add external DNS forwarders, and apply security hardening (e.g., disable SMBv1).
    • Automation: 05-Post-Configuration.ps1 reconfigures DNS, adds forwarders (e.g., 8.8.8.8, 8.8.4.4), and applies security settings tailored for MSP environments, reducing the need for manual hardening.

Benefits of Automation

Key Features

This project is designed with production environments in mind, offering several features that make it ideal for MSPs:

Security Hardening for MSP Environments

Security is a top priority, especially in MSP environments where Domain Controllers often coexist with other critical infrastructure components, such as an Ansible control node. The 05-Post-Configuration.ps1 script includes several security measures to harden the DC:

These measures ensure that the DC is not only functional but also secure and ready for integration with automation tools like Ansible.

Usage and Configuration

To use these scripts, follow these steps:

  1. Clone the Repository:
    git clone https://github.com/marky224/Active-Directory-Domain-Controller-Provisioning.git
    cd Active-Directory-Domain-Controller-Provisioning
  2. Ensure Prerequisites Are Met:
    • Fresh installation of Windows Server 2025.
    • Administrative privileges.
    • Server in bridged mode or on a physical network with a reserved static IP (e.g., 192.168.0.10).
    • Internet access with Google DNS (8.8.8.8).
    • At least 20 GB of free disk space.
  3. Run the Scripts in Sequence:

    Copy the scripts to C:\Configuration\ on the target server and execute them in order:

    .\00-Install-Updates.ps1      # Optional: Installs updates
    .\01-Check-Prerequisites.ps1  # Validates environment
    .\02-Set-StaticIP.ps1         # Configures network settings
    .\03-Install-ADDSRole.ps1     # Installs AD DS role
    .\04-Promote-DomainController.ps1  # Promotes server to DC
    .\05-Post-Configuration.ps1   # Finalizes setup
  4. Verify Logs:

    Check C:\ADSetup\ for detailed logs and troubleshooting information.

Currently, the scripts use standard AD defaults for configurations like IP addresses and forest names. In future updates, I plan to introduce a JSON configuration file to allow for greater customization, making the scripts even more versatile for different environments.

Conclusion

This project demonstrates how automation can transform a traditionally manual and error-prone process into a streamlined, efficient, and secure operation. By automating the provisioning of Active Directory Domain Controllers, MSPs can save time, reduce errors, and ensure consistent deployments across client environments. As part of my broader network virtualization project, this repository lays the groundwork for more advanced configurations and integrations, with future updates planned to enhance customization and flexibility.

For more details, visit the GitHub repository.

Mark’s Project Portfolio