Windows Server 2012 R2 VM
Windows Server 2012 R2 VM creation on a Linux host using KVM
This process gives us a fairly minimal Windows Server 2012 R2 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="win2012R2-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
# Copy the base image to the VM specific directory:
rsync --progress ~/VMs/base_images/win-serv-2012R2-c-base.qcow2 ~/VMs/${VMNAME}/${VMNAME}-c.qcow2
# 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/VirtIO-Win/2020/virtio-win-0.1.173.iso" \
--os-variant "win2k12" \
--graphics spice \
--network=bridge:virbr0 \
--boot hd \
--noautoconsole \
--import
Installing VirtIO drivers
After the OS has been initialized the system will automatically shut down. 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
This will install the Virtual IO drivers, QEMU guest agent and the SPICE 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 "win2012R2-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 latest PowerShell v5 version
Run the following in an administrative level PowerShell instance:
# Version before
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
# 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
Invoke-WebRequest `
-Uri "https://download.microsoft.com/download/6/f/5/6f5ff66c-6775-42b0-86c4-47d41f2da187/Win8.1AndW2K12R2-KB3191564-x64.msu" `
-OutFile "$DownloadsPath\Win8.1AndW2K12R2-KB3191564-x64.msu"
# Install PowerShell 5.1 - This will prompt to restart your system
wusa.exe "$DownloadsPath\Win8.1AndW2K12R2-KB3191564-x64.msu" /quiet /promptrestart
# Version after
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1005
Installing PowerShell 7
Install the latest available version of PowerShell on Windows Server 2012 R2, this installs to: C:\Program Files\PowerShell\7
# Version before
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1005
# Windows Server 2012 R2 does not use TLS 1.3 as most modern sites expect
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Upgrade to PowerShell 7 (LTS)
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -useMSI -Quiet -EnablePSRemoting"
# Version after
$PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 5 4
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
Optional Installs
Installing IIS
# Determine the path to the users Downloads folder
$DownloadsPath = (New-Object -ComObject Shell.Application).Namespace('shell:Downloads').Self.Path
Install-WindowsFeature `
–ConfigurationFilePath "$DownloadsPath\ConfigurationFiles\IIS_Win2012R2_Deployment_Config_Template.xml"
# Result:
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Centralized SSL Certificate Support, Comm...