The four different user interfaces in Windows Server 2012

This article explains the four different user interface modes or options in Windows Server 2012 and how to change from one to the other. I also provide a simple PowerShell script for the purpose.

The “four horsemen”

In previous versions of Windows Server you had to make the choice between Server Core and Full GUI during the initial installation and it was a one time decision. You couldn’t go back and change it afterwards. Microsoft has answered the call and all this has changed with Windows Server 2012. We now have four (that’s right, four) options to choose from. The two are the familiar ones, Server Core and Full GUI, and you still choose one or the other during OS installation. The remaining two are called Minimal Server Interface and Full GUI with Desktop Experience.

The differences between the four are actually just a matter of three Windows features. What determines the UI mode (or installation state as it is called in some documentation) is the installation state of these features. This is best described in the form of a table.

Server Core Minimal Server Interface Server with a GUI Desktop Experience added
Windows Features none Graphical Management Tools and Infrastructure Graphical Management Tools and Infrastructure, Server Graphical Shell Graphical Management Tools and Infrastructure, Server Graphical Shell, Desktop Experience
Install-WindowsFeature none Server-Gui-Mgmt-Infra Server-Gui-Mgmt-Infra, Server-Gui-Shell Server-Gui-Mgmt-Infra, Server-Gui-Shell, Desktop-Experience

You start with the Server Core with none of the three features installed. Go on and add Server-Gui-Mgmt-Infra and you get the Minimal Server Interface. Moving forward and install the Server-Gui-Shell and you have yourself the full blown and familiar Graphical User Interface. Then, if for some reason, you want aero and media player and all the fancy desktop stuff on your server, you add the Desktop Experience.

It is also worthwhile mentioning that these are all dependent on the previous one. So you can only go from Core to Minimal Interface to Full GUI to Desktop Experience and backwards. You can’t go from Minimal Server Interface to Desktop Experience without adding the Server-Gui-Shell with it. Got it?

How to do it?

The two PowerShell cmdlets needed are Install-WindowsFeature and UnInstall-WindowsFeature. There exists also Add-WindowsFeature and Remove-WindowsFeature, but they are only aliases for the previously mentioned.

So, to switch from Server Core to a Minimal Server Interface, you say (in an elevated PowerShell session):

Install-WindowsFeature Server-Gui-Mgmt-Infra
Restart-Computer

…or just in a one-liner:

Install-WindowsFeature Server-Gui-Mgmt-Infra -Restart

To go back from a Server with a GUI installation option to Server Core, you say (make note of the backtick mark):

UnInstall-WindowsFeature Server-Gui-Mgmt-Infra, `
Server-Gui-Shell -Restart

Simple enough? Hold your horses, there’s a twist. Namely, the Features on Demand functionality.

Features on Demand

To save disk space and make the attack surface of the server OS smaller Microsoft introduced Features on Demand. It’s kinda going back in time. Remember with previous versions of Windows Server when you wanted to add a role or a feature, you had to dig up the installation media. Well, that’s just what Features on Demand basically is. It removes the binaries from the disk when you remove stuff from the installation. This wasn’t the case with Windows Server 2008 R2 where you had all of the DVD bits laying around in each and every server instance in your fancy private cloud. Not so smart disk space usage wise, you’d say? Anyways, if you say:

UnInstall-WindowsFeature some-great-feature -Remove

the binaries of some-great-feature are removed from the disk. If you later on decide to install the feature again, you’re going to need the source files from the installation media.

What does this has to do with any of this? Well, if you go for the Server with a GUI from the beginning, you might not run into this. But if you choose the Server Core from the get-go, you’re gonna have to pay attention. With the Server Core installation state, the binaries for Minimal Server Interface and Full GUI are not copied to the system volume during installation. When you later on decide to add the features, you need to provide the binaries from the installation media to the Install-WindowsFeature cmdlet. You do this by providing the Source parameter. The source can be the original DVD media, contents of it copied to a network share or a wim file (mounted or not). For example:

Install-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell `
-Source wim:d:\sources\install.wim:1 -Restart

…or…

Install-WindowsFeature Desktop-Experience -Source \\some_UNC_path -Restart

When run, the installation searches for the sources in the provided location. Or, when the source parameter is omitted, it goes to Windows Update for them.

The Script

Now that we understand what’s going on here, it’s time to make it easier to repeat server after server. And that’s what scripting is all about. Here we go:

# A script to switch between the installation states
# in Windows Server 2012. The UI states are:
#   Server Core
#   Minimal Server Interface
#   Full UI
#
# Usage: Takes in two parameters ($Source_path and $Target_mode)
#        $Source_path contains the source location
#        $Target_mode is one of the following:
#          Core
#          GUI
#          Minimal
#
# Author: Mikko Viitaila
# Date:   02/05/2013
#

# Let's parse the parameters
param([string]$Source_path = "put_your_default_source_location_here",
      [string]$Target_mode = "Core")

# Strict-Mode, this is important!
Set-StrictMode -Version Latest

Function Switch-to-Core { 
[Cmdletbinding()] 
Param() 
    # Switch to Server Core
    Write-Verbose "Removing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra"
    Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra 

    # Change PowerShell as the Shell
    Write-Verbose "Changing PowerShell as the Shell"
    $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
    Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"' -Force

    # Now restart the system 
    Write-Verbose "Finished, restarting..." 
    Restart-Computer 
} 

Function Switch-to-Full-GUI {
[Cmdletbinding()]
Param()
    # Switch to Full GUI
    Write-Verbose "Installing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra"
    Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source $Source_path

    # Remove the Shell Settings from the registry
    Write-Verbose 'Removing Shell settings from registry'
    $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
    Remove-ItemProperty -Confirm -Path $RegPath -Name Shell -ErrorAction SilentlyContinue

    # Now restart the system 
    Write-Verbose "Finished, restarting..." 
    Restart-Computer 
}

Function Switch-to-MinimalServerInterface {
[Cmdletbinding()]
Param()
    # Install GUI
    Write-Verbose "Installing Windows Feature: Server-Gui-Mgmt-Infra"
    Install-WindowsFeature Server-Gui-Mgmt-Infra -Source $Source_path

    # Remove GUI Shell
    Write-Verbose "Uninstalling Windows Feature: Server-GUI-Shell"
    Uninstall-WindowsFeature Server-Gui-Shell

    # Change PowerShell as the Shell
    Write-Verbose "Changing PowerShell as the Shell"
    $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
    Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"' -Force

    # Now restart the system 
    Write-Verbose "Finished, restarting..." 
    Restart-Computer 
}

# script execution begins
switch ($Target_mode) {
    "Core" { Switch-to-Core }
    "GUI"  { Switch-to-GUI }
    "Minimal" { Switch-to-MinimalServerInterface }
}

That’s it. We now have a script that we can use to easily switch between the different installation states of Windows Server 2012. I don’t need the Desktop Experience mode, so that’s not included in the script. It can be easily extended to cover that too, if you want. Also, as an added bonus, switching to the Server Core and Minimal Server Interface modes include changing the default shell to PowerShell instead of the good old cmd.exe. PowerShell is the environment we want these days, right?

Sources: TechNet

3 thoughts on “The four different user interfaces in Windows Server 2012

Leave a Reply

Your email address will not be published. Required fields are marked *

Please, do the math and help fight spam * Time limit is exhausted. Please reload the CAPTCHA.