Configure a Windows Server
Context
In almost all classes concerning Windows Server at IPI, I had to reinstall a Windows Server with AD DS, DNS, DHCP manually in VMWare Workstation. So, I decided to create this script to automate the entire process with preconfigured IP configurations.
Step-by-step Script Breakdown
Renaming the Server
Prompt the user to enter a new name for the server, then rename the machine (~5 seconds).
Network Configuration
Configure the static IP address, subnet mask, default gateway, and DNS server address with predefined values (~3 seconds).
Enabling Autologon
Set up Autologon so the user automatically logs in after a reboot, saving their password in the registry (~3 seconds).
Creating the Scripts Folder
Create a folder to store additional scripts required for configuration (~5 seconds).
Creating and Executing the First Script (2adds.ps1
)
Create the script to install and configure Active Directory Domain Services (AD DS), then schedule its execution after a reboot (~5 seconds).
Configuring DNS and DHCP (3dns.ps1
)
Create the script to configure the DNS zone and install the DHCP service, then schedule its execution after a reboot (~5 seconds).
Restarting the Server
Restart the server to apply the changes, ensuring that scheduled tasks resume after the reboot (~180 seconds).
Disabling Autologon and Cleaning Up
Disable Autologon and clean up credentials in the registry after the scripts finish (~5 seconds).
This script is to be executed once the Windows Server virtual machine is freshly installed.