DEV Community

Cover image for From Installation Freezes to PowerShell Automation: My Windows Server 2019 Journey.
Zakariyau Mukhtar
Zakariyau Mukhtar

Posted on

From Installation Freezes to PowerShell Automation: My Windows Server 2019 Journey.

Introduction: The Challenge

I recently tackled a comprehensive lab project: deploying a functional Windows Server 2019 environment from scratch. The goal wasn't just to install the OS, but to configure it like a real-world sysadmin using automation to handle users, groups, and secure file sharing.

While I started this project feeling a bit like a beginner (or as we say, an "olodo"), by the end, I was writing multi-line PowerShell scripts to manage the infrastructure.

Here is a breakdown of how I built my lab using Oracle VirtualBox and how I overcame some tricky hurdles along the way.


Phase 1: The Setup and "The Freeze"

My lab environment ran on Oracle VirtualBox. The installation process taught me my first major lesson in virtualization troubleshooting.

Initially, my Windows Server installation kept freezing at the "spinning dots" boot screen. After some deep diving into settings, I realized that running a modern server OS requires specific virtualization hardware settings.

The Fix:
It turned out my VM configuration was missing a critical processor feature. I had to ensure PAE/NX was enabled in the VirtualBox processor settings and increase my video memory. Once those were tweaked, the installation sailed through to the desktop experience.


Phase 2: Base Configuration (The Manual Stuff)

Once logged in as the Administrator, the first step was giving the server an identity.

In a real network, servers need static addresses so they can always be found. I configured the network adapter with a static IPv4 address suitable for my lab environment (10.0.2.15).

I also renamed the computer from its generic Windows name to something meaningful: WIN-SERVER-01. While I could have used the GUI, I used PowerShell for a quick rename and restart:

Rename-Computer -NewName "WIN-SERVER-01" -Restart

Enter fullscreen mode Exit fullscreen mode

Phase 3: The Power of Automation (The Cool Stuff)

This is where the project got interesting. The requirement was to create multiple users (Alice, Bob, Charlie), assign them to departments (HR, IT), and ensure they changed their passwords on first login.

Doing this manually involves dozens of clicks. Instead, I wrote a PowerShell script to handle it in seconds.

The Scripting Approach:
I used ISE to write a script that utilized loops and conditionals. It checked if a user or group existed before trying to create it, making the script "idempotent" (safe to run multiple times).

Here is a snippet of the user creation loop:

# Snippet: Automating User Creation
$users = @("Alice", "Bob", "Charlie")
foreach ($user in $users) {
    # Create the user
    New-LocalUser -Name $user -Password $securePassword -Description "Staff"

    # Force password change at next login
    $userObj = [ADSI]"WinNT://$env:COMPUTERNAME/$user,user"
    $userObj.PasswordExpired = 1
    $userObj.SetInfo()
}

Enter fullscreen mode Exit fullscreen mode

Users scripts


Phase 4: Permissions and Hardening

The final step was securing the environment.

File Sharing:
I created restricted folders HRDocs and ITDocs. I used PowerShell to ensure only the HR group could access their documents, and ditto for IT. This enforced the principle of least privilege.

Security Hardening:
As a basic security measure, I disabled the built-in Guest account to prevent anonymous access. Again, PowerShell made this easy to verify:

Security Hardening


Conclusion and Lessons Learned

This project was a great crash course in Windows Server administration. The biggest takeaway wasn't just knowing what to configure, but knowing how to do it efficiently.

While GUIs are helpful for learning, PowerShell is essential for scalable, repeatable system administration. Moving past the initial installation hurdles and seeing my scripts successfully deploy the environment felt like a massive win.

Top comments (0)