Skip to main content

Windows Server 2016 VM

Windows Server 2016 VM creation on a Linux host using KVM

This process gives us a fairly minimal Windows Server 2016 VM running under KVM. This process has only been tested on Fedora Linux.

Define the VM name and location

# Define the new VM name:
export VMNAME="win2016-01"
mkdir -p ~/VMs/"${VMNAME}"
cd ~/VMs/"${VMNAME}"

# Set a custom folder icon with GNOME:
gio set -t string ${HOME}/VMs/${VMNAME} metadata::custom-icon file://${HOME}/Pictures/icons/folder-windows-server-2025.png

Creating the VM

No VHD is available, only an ISO, so we need to install the OS to a clean OS disk.

# Make qcow file for the C: drive for a clean OS install
qemu-img create -f qcow2 "${HOME}/VMs/${VMNAME}/${VMNAME}-c.qcow2" "32G"

# Create the VM:
virt-install \
--connect qemu:///session \
--hvm \
--name "${VMNAME}" \
--memory "8192" \
--vcpus "2" \
--disk path="${HOME}/VMs/${VMNAME}/${VMNAME}-c.qcow2",bus=sata \
--cdrom "${HOME}/VMs/ISOs/Windows/2016/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO" \
--os-variant "win2k16" \
--graphics spice \
--network=bridge:virbr0 \
--boot cdrom,hd \
--noautoconsole \
--import

Select the Windows Server 2016 Datacenter Evaluation (Desktop Experience) option when prompted.

Installing VirtIO drivers

After the OS has been installed the system will automatically shut down. When this happens, attach the ISO from: ~/VMs/ISOs/Windows/VirtIO-Win/latest Start the system back up, set the default Administrator password (See Keeper) and login. Run the following application from the DVD and accept all the defaults:

virtio-win-guest-tools

Eject the ISO from the VM when the install has completed. Do not reboot yet!

Set the desktop resolution to: 2560 x 1600 at 150% scale.
Run the PowerShell script at: Set background colors for Windows desktops to set the intended desktop color.

Set the hostname

Set the hostname via an administrative level PowerShell instance:

Rename-Computer -NewName "win2016-01"

A system restart will be required for this to take effect, but do not reboot yet!

Set the time zone

Run the tzutil CLI utility in an administrative level PowerShell instance:

tzutil /s "UTC"

Ensure the system clock matches wall time after setting this.

Windows Update

Run the sconfig CLI utility in an administrative level PowerShell instance:

sconfig
# Option 5 - Enable Automatic updates
# Option 6 - Install updates
# Choose 1 to search for All updates
# then A again to install All updates
# Restart when requested

Install all available updates and reboot. This step may have to be run 3 times to get all of the updates installed. Continue until no more updates are available.

Installing PowerShell 7

Install the latest available version of PowerShell on Windows Server 2016, this installs to: C:\Program Files\PowerShell\7

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -useMSI -Quiet -EnablePSRemoting"

There will be a new PowerShell 7 (x64) item on the Start Menu. You should right click on this item and select: Pin to Start

Install Git etc.

Here we’ll install a few basic utilities to make our life easier:

# Determine the path to the users Downloads folder
$DownloadsPath = (New-Object -ComObject Shell.Application).Namespace('shell:Downloads').Self.Path

# Windows Server 2012 R2 does not use TLS 1.3 as most modern sites expect
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Download Git
Invoke-WebRequest `
-Uri "https://github.com/git-for-windows/git/releases/download/v2.51.2.windows.1/Git-2.51.2-64-bit.exe" `
-OutFile "$DownloadsPath\Git-2.51.2-64-bit.exe"

# Download Notepad++
Invoke-WebRequest `
-Uri "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.9.5/npp.8.9.5.Installer.x64.exe" `
-OutFile "$DownloadsPath\npp.8.9.5.Installer.x64.exe"

# Download 7-Zip
Invoke-WebRequest `
-Uri "https://www.7-zip.org/a/7z2501-x64.exe" `
-OutFile "$DownloadsPath\7z2501-x64.exe"

You can manually install these apps using the defaults.

Install marcosnils/bin for managing random binaries

bin is a lightweight, cross-platform binary manager that simplifies downloading, installing, and managing binaries without requiring root privileges. See the doc at: bin - Effortless binary manager

Uninstall PowerShell ISE

This tool does not support PowerShell 7 therefore it should be removed from the system and its usage discouraged.

dism /online /disable-feature /featurename:MicrosoftWindowsPowerShellISE

Expected response:

Deployment Image Servicing and Management tool
Version: 10.0.14393.4169

Image Version: 10.0.14393.7426

Disabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Optional Installs

Installing IIS

Install-WindowsFeature -name Web-Server -IncludeManagementTools

Expected response:

Success Restart Needed Exit Code      Feature Result
------- -------------- --------- --------------
True No Success {Common HTTP Features, Default Document, Dir…

Verify what features are installed:

Get-WindowsFeature | Where-Object {$_.Installed -eq $true} | Format-Table Name, InstallState

Expected result:

Name                      InstallState
---- ------------
FileAndStorage-Services Installed
Storage-Services Installed
Web-Server Installed
Web-WebServer Installed
Web-Common-Http Installed
Web-Default-Doc Installed
Web-Dir-Browsing Installed
Web-Http-Errors Installed
Web-Static-Content Installed
Web-Health Installed
Web-Http-Logging Installed
Web-Performance Installed
Web-Stat-Compression Installed
Web-Security Installed
Web-Filtering Installed
Web-Mgmt-Tools Installed
Web-Mgmt-Console Installed
NET-Framework-45-Features Installed
NET-Framework-45-Core Installed
NET-WCF-Services45 Installed
NET-WCF-TCP-PortSharing45 Installed
Windows-Defender Installed
System-DataArchiver Installed
WindowsAdminCenterSetup Installed
PowerShellRoot Installed
PowerShell Installed
Wireless-Networking Installed
WoW64-Support Installed
XPS-Viewer Installed