There is a Windows Server edition which takes less attention that it deserves. This is the Microsoft Windows Server Core. It has only a command prompt to administrate the server, but runs several roles and has many benefits.

Server Core is capable of the following server roles:

  • Active Directory (AD)
  • Active Directory Lightweight Directory Services (ADLDS)
  • DHCP Server
  • DNS Server
  • File Services
  • BITS Server
  • BranchCache
  • HyperV
  • IIS
  • Printing Services
  • Streaming Media Services
  • iSCSI
  • Load Balancing
  • MPIO
  • qWave
  • Telnet
  • Unix Migration
  • Active Directory Certificate Services

The purpose of using the Server Core instead of the Standard or Enterprise edition is the following:

BenefitDescription
Reduced ServicingBecause Server Core installs only what is required for a manageable DHCP, File, DNS, Media Services, and Active Directory server, less servicing is required.
Reduced ManagementBecause less is installed on a Server Core-based server, less management is required.
Reduced attack surfaceBecause there is less running on the server, there is less attack surface.

A very simple usage example is, if you want to create a virtualization environment based on HyperV. Under HyperV Server you do not need a full Windows Server.

But using windows core server could lead to problems. For example there are some roles which needs GUI. In the previous versions you had to reinstall your Server but with the current release which is 2012 you can install GUI with a simple powershell script. You need to open a powershell console (even from remotely) and run the following scripts:
Import-Module Dism
Enable-WindowsOptionalFeature –online -Featurename ServerCore-FullServer,Server-Gui-Shell,Server-Gui-Mgmt

It takes a few minutes and after a reboot you have the full GUI environment.

These abilities are working in both ways. So if you can better manage a WinServer via GUI, you can simply install it as a normal server with GUI and after setting up all the services, roles, you can remove the GUI.
The needed PowerShell script is the following:
Import-module servermanager
Uninstall-windowsfeature -name Server-GUI-Mgmt-Infra,Server-GUI-Shell
RESTART-Computer

What happens if you install Windows Server 2012 without the GUI features and then realize that you want to turn on the GUI? For those who are used to GUI based Windows Server administration, seeing a command line interface can be daunting. This guide will help you to go from the command line interface, using PowerShell, to installing and turning on the GUI.

Install the GUI on Windows Server 2012

The first step in this is to enter the PowerShell. At the command line prompt, just enter PowerShell and you will see something like the below:

Windows Server 2012 – Turn on GUI – PowerShell

The next step is to type Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra in order to get the

Windows Server 2012 – Turn on GUI – Install GUI

You will see a text based installer. This part of the Windows Server 2012 GUI installation is rather easy and there is plenty of time to grab a drink.

Windows Server 2012 – Turn on GUI – Grab a Drink During Install

Once this is complete, you do need to reboot the server before the GUI will be turned on. Unless you have something else going on that you need to shutdown first, you can shutdown and reboot immediately with shutdown -r -t 0 as seen below:

How to turn the gui off and on in windows server 2012

Windows Server 2012 – Turn on GUI – Reboot

The system will then reboot and go through the Windows Server 2012 configuration changes.

How to turn the gui off and on in windows server 2012

Windows Server 2012 – Turn on GUI – Configuring Features

When the system boots, you will see that the GUI is turned on. The Server Manager dashboard is present on login and everything works.

How to turn the gui off and on in windows server 2012

Windows Server 2012 – Turn on GUI – Installation Successful

Conclusion

If you are accustomed to the Windows Server 2012 GUI, you may be a bit nervous seeing a command line only interface. Fear not, the guide above uses less than 90 characters of typing to install and turn on the GUI. In total this took me only a few minutes to do the run-through. Also, this guide assumed one has a command line only installation. If you already have the GUI installed, you can use SConfig to turn on the GUI easily.

When Server Core originally shipped, a lot of Windows admins avoided it because you could only use the command line, but this changes with Windows Server 2012 which enabled the use of a hybrid mode.

Turning the GUI Off

In Windows Server 8 the GUI has kept with the modular nature of recent Windows Server Operating Systems and in turn has become a “Feature”. This makes removing the GUI very easy. To get started launch Server Manager.

Click on Manage, and then select Remove Roles or Features from the menu.

Click next to skip past the before you begin page, then select your server from the server pool and click next.

Since the GUI is not a Role, we can just click next again to skip past the Roles section.

When you reach the Features page, you need to uncheck the box next to the “User Interfaces and Infrastructure” option, and then click next.

Now tick the “Restart Destination Server” box, then click remove.

The GUI will now be removed.

After the binaries are removed your server will automatically reboot.

Once it comes back up, and you log in, you will only be able to use the command line.

Turning the GUI On

Once the GUI has been turned off, you will want to know how to get it back. To do this we use SConfig, so go ahead and type SConfig into the command line and hit enter.

You can see near the bottom of the screen that we can use “12” to Restore the GUI, so type 12 and hit enter.

You will be warned that enabling the GUI requires a reboot, click the yes button.

That will kick off DISM which will start to add the binaries for the GUI Shell.

When its finished you will be asked if you would like to restart the computer now, type “y” and hit enter to reboot.

GUI Off with PowerShell

You can do the same thing as we did in the GUI much quicker with a PowerShell cmdlet. To do so, open Server Manager, click on Tools and launch PowerShell.

We can use the Remove-WindowsFeature cmdlet to remove the feature:

Remove-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

Since Remove-WindowsFeature is just an alias, you could also use:

Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

Not long after you have hit the enter key, the removal will begin.

When it’s done, you will be notified that you need to restart your server to complete the process, which can be easily done from the current PowerShell window by running:

When your machine restarts you will only have the command line to work with .

GUI On with PowerShell

The first thing we need to do is get into PowerShell, so type PowerShell and hit enter.

Now we need to use the Add-WindowsFeature to add the components back:

Add-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

Again this is just an alias for:

Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

When its done, we will need to restart our server by using the Shutdown command:

When Server Core originally shipped, a lot of Windows admins avoided it because you could only use the command line, but this changes with Windows Server 2012 which enabled the use of a hybrid mode.

Step 1: Go into Server Manager > Manage > Remove Roles and Features

How to turn the gui off and on in windows server 2012

Step 2: Pick the server you want to remove the feature from:

How to turn the gui off and on in windows server 2012

How to turn the gui off and on in windows server 2012

Step 3: From the “Remove Roles and Feature Wizard” – Click on User Interfaces and Infrastructure

Step 4: Click on “Remove Features

How to turn the gui off and on in windows server 2012

How to turn the gui off and on in windows server 2012

Step 5: Make sure to check off: “Restart the destination server automatically if required

Step 6: Once the server is rebooted and you log into it, you are finally in Core. Congrats!

Server Core was introduced in Windows Server 2008 but was confusing to many administrators. This was mainly because that you, as an administrator, were restricted to a command line and needed to know the commands for doing your tasks.

One of the main problems with it was that if you installed your server as a Server Core, you would need to reinstall it if you want the graphical user interface (GUI).

This changed in Windows Server 2012. It was now possible to install your server with a GUI and remove the GUI once you’ve set everything up.

It was also possible to install your server as a Server Core and then add the GUI by just entering a simple Powershell command.

In this blog post, I will explain how to install the GUI for a Windows Server Core installation or remove the GUI if you have Windows Server 2012 or Windows Server 2012 R2.

How to install the GUI for Windows Server 2012 R2 Core

Enter this command into a Powershell prompt, running as Administrator.

How to turn the gui off and on in windows server 2012

Once installed, you need to restart the server. Use this command:

If you do not have Internet connectivity, the installation will hang at 68% and, after a while, displays an error message to you:

Install-WindowsFeature: The request to add or remove features on the specified server failed.

This means that the source files for the GUI installation cannot be located.

How to turn the gui off and on in windows server 2012

To solve the error, follow these steps:

Start by creating a mount directory (i.e C:\Mount), by opening a command prompt:

Get the index number of the WIM file for the GUI (if Windows Server 2012 R2 media is on D:). Since all of the Windows Server 2012 R2 installations are stored in the same *.wim, we need to specify what version we want to mount. In this case, we’ll be using the Datacenter version with GUI, which is Index #4

How to turn the gui off and on in windows server 2012

Mount the WIM file:

Install and specify the source:

Once installed, you need to restart the server. Use this command:

How to turn the gui off and on in windows server 2012

How to remove the GUI from a full installation, using the GUI:

Open Server Manager, open the Manage menu and go to Remove Roles and Features

Press Next until you reach the Features page

There are two different features that you can choose:

  • Graphical Management Tools and Infrastructure (server-GUI-mgmt-infra) basically provides Powershell, MMC, and Server Manager.
  • Adding the Server Graphical Shell (server-GUI-shell) will add the rest of the GUI experience. This feature is dependent on the first, so you can’t just add this one.

Note that if you remove Graphical Management Tools and Infrastructure, you will also remove Server Graphical Shell.

How to turn the gui off and on in windows server 2012

Once deselecting one of the features, you will get a popup. Here, press Remove Features.

How to turn the gui off and on in windows server 2012

The User Interfaces and Infrastructure feature should now be deselected. Proceed by pressing Next.

The final step is to confirm the removal process. Press Remove and select Restart the destination server automatically if required.

Most of us might not be aware that there is a Windows Core version, which has only command-line without any GUI.

This core version relatively provides high level of security, as all GUI interface are removed, which also increases the performance of the system.

This might be helpful if you are running Windows server.

Up until Windows Server 2008, once you install the core version, or the full GUI version, you cannot switch back.

However in Windows Server 2012, it provides the following three modes, and you can easily switch between GUI to core, and core to GUI.

  1. Nomal GUI mode – The standard OS with full GUI features.
  2. Graphical mode – Management tools and Infrastructure. This mode provides only few essential GUI tools. For example, management tools like Server manger, Disk management console, etc.
  3. Core mode – No GUI in this mode. You’ll get only command prompt with powershell.

This tutorial explains how you can switch from Core version to GUI mode, and from GUI mode to Core version.

I. Switch from Core Version to GUI Mode

1. Launch Powershell

From the command prompt, launch the powershell as shown below.

2. Import Server Modules

By default, to increase the server performance, all modules and commands are not loaded in server. We have to import the modules using the following command:

3. Change User Interface Mode

To change user interface from Command mode to GUI mode:

For full GUI mode:

For graphical management tools and infrastructure:

To change user interface from GUI mode to command mode:

For full command (core) mode:

For graphical management tools and infrastructure:

For our example, let us do the following:

After entering the above command, it will extract all binary files and start the installation. After completing installation server will reboot automatically. When the system starts, Windows will be running in the new mode.

How to turn the gui off and on in windows server 2012

II. Switch from GUI to Core Command Mode

1. Launch “Remove Roles and Features”

Open server manger -> Select “Manage” from the menu -> Select “Remove Roles and Features” as shown below.

How to turn the gui off and on in windows server 2012

Press next on the welcome page.

In the next screen, select the server from the server pool. By default our local server is selected, but we can perform add/remove feature task to remove server by adding server IP in server pool.

2. Select User Interface Features

Now, you can select or unselect the options under user interface and infrastructure features option as per your requirement.

To change user interface from GUI mode to Command mode:

For full command (core) mode: Uncheck both “Graphical Management and infrastructure” and “Server Graphical shell”.

For graphical management tools and infrastructure: Uncheck only “Server Graphical shell” option

How to turn the gui off and on in windows server 2012

3. Remove GUI Features

Select the features that you like to remove. This will also automatically select any dependent features that needs to be removed.

How to turn the gui off and on in windows server 2012

After the above step, the server will reboot. After the reboot, when the system comes back up, you’ll see not see GUI anymore. You’ll get only the command prompt with powershell.

A couple of days ago I was doing a deployment. It was one of those days where nothing seemed to work. Everyone is familiar with them and probably detest them as much as I do: the type of non-productive days where nothing productive gets done.

I actually had a lot of setbacks. Firewalls being too restrictive. Network traffic not routed correctly. Group Policy Objects (GPOs) magically breaking my clients Active Directory connections. And then, instead of throwing my laptop, I wanted to start from scratch with the server I was working on at that particular moment.

I got a little more than I bargained for. So in my infuriated state I decided it was a good idea to remove all features and roles from the server. I opened server manager, choose to remove roles and features, and deselected all options, not really paying attention to what I was doing.

How to turn the gui off and on in windows server 2012

The Server Manager gave me a summary of the jobs at hand, but of course I did not read it. I clicked the close button and went for a cup of coffee.

How to turn the gui off and on in windows server 2012

When I came back the server innocently asked me to reboot it. Suggesting that was needed to complete the task I had assigned. Giving it no secondary thought I gave the command to shutdown forced and reboot immediately.

When it came back up, I logged in and was happily greeted by a command prompt shell. Thinking I accidentally uninstalled the graphical user interface from Windows Server 2012, I wasn’t worried for a second. So I gave command to start PowerShell and was presented with the following error message.

How to turn the gui off and on in windows server 2012

What did I just do? Uninstall everything. And I really mean everything. Turns out that unchecking everything includes .NET 4.5 and thus removing everything, leaves your server quite useless. Something like a Windows 2008 Server Core installation.

Then I remembered “Deployment Image Servicing and Management”. Usually referred to as DISM. First, I checked what features where available. I put the output to a text file because otherwise it wouldn’t be really readable.

DISM /Online /Get-Features > features.txt

How to turn the gui off and on in windows server 2012

As you can see, almost everything is disabled. This gives new meaning to “build from scratch”.

PowerShell Engage

then I used the following command to install PowerShell again:

DISM /Online /Enable-Feature:MicrosoftWindowsPowerShell /all

Notice the /all switch at the end of the command. This tells DISM to install the prerequisites as well.

How to turn the gui off and on in windows server 2012

The PowerShell command now works again.

To the GUI

Still there is no Graphical User Interface. And for the sake of this blog I used DISM to install that as well:

DISM /Online /Enable-Feature:Server-GUI-Shell /all

This will ask for a reboot.

Then the server will install the GUI again and will be manageable by IT Pros who don’t like the command line that much.

How to turn the gui off and on in windows server 2012

And after this operation completes and you log in, the GUI is back.

How to turn the gui off and on in windows server 2012

Then I went on with the deployment as planned and this server is now running the Remote Access Role and configured to manage DirectAccess for a couple of Windows 8 clients. It’s running this without any problems.

To Sum up

You can remove PowerShell from Windows Server 2012 by using the Server Manager and selecting the Remove Roles and Features option.

Afterwards you will boot into a Command Prompt where PowerShell will not work because it is not enabled.

I used the following DISM commands to enable the feature again:

DISM /Online /Enable-Feature:MicrosoftWindowsPowerShell /all

With PowerShell enabled, it should be a breeze to fix the server some more.

Keep in mind that this server still had its source files. There are methods to Categories PowerShell, Windows Server 2012

In this post we will take a look at switching between GUI and Server core in Windows Server 2012. One of the most interesting feature in Windows server 2012 is it allows you to switch from GUI mode to Core mode.

In other words GUI mode in windows server 2012 is optional, that means you can uninstall the GUI and install it back whenever required.

In the previous post we saw the installation of Windows Server 2012 in core mode, during the installation of windows server 2012 the user is asked to choose between server core installation and server with a GUI installation.

The benefits of installing windows server 2012 in core mode includes reduced attack surface, reduced maintenance, server consumes fewer hardware resources than server installed in GUI mode.

Note that when you browse the internet looking for switching between GUI and Core in server 2012 you might find the scripts written by IT professionals that will help you switch between GUI and Server core. In this post we will doing it without using any scripts.

Switching from Windows Server 2012 Core to GUI

I have installed Windows Server 2012 Datacenter Edition (Server Core Installation) on a virtual machine. I have mounted the Windows Server 2012 DVD on to the virtual machine.

Log in to the server with the administrator account and you must see a command prompt.

We will be creating two folders, Install and Mount. The folder Install will contain the Install.wim copied from the source DVD and folder Mount will contain the Install.wim, this folder is used for the purpose of mounting Install.wim.

Create two folders Install and Mount using mkdir command.

How to turn the gui off and on in windows server 2012

Change drive to where you have mounted Windows Server 2012 DVD.

In my case it’s the D drive where the DVD is mounted, next step is to change your directory to Sources where the Install.wim is present.

How to turn the gui off and on in windows server 2012

Lets get the details about the Image that we have mounted. Use the command “dism /get-wiminfo /Wimfile:.

In the below screenshot we can see that there are 2 editions of windows server 2012, Standard and Datacenter each with core and GUI mode.

We will be using Windows Server 2012 Datacenter edition for installing the server features. Make a note of Index number which will be helpful while mounting the file.

How to turn the gui off and on in windows server 2012

To mount the .wim file, use the command “dism /mount-wim /wimfile: /Index:Indexnumber /mountdir: /readonly”.

How to turn the gui off and on in windows server 2012

To install the GUI and Server Manager use the powershell command Install-WindowsFeature Server-GUI-Mgmt-Infra, Server-GUI-Shell -Source .

Always remember to specify the Source folder. The feature installation may fail if you don’t specify the source folder.

The feature installation now begins.

How to turn the gui off and on in windows server 2012

You must restart the computer.

How to turn the gui off and on in windows server 2012

Login to the computer with the Administrator account.

How to turn the gui off and on in windows server 2012

We see that the Server manager is installed and GUI too. We have switched from Server core mode to GUI mode successfully.

How to turn the gui off and on in windows server 2012

Switching from Windows Server 2012 GUI to Core

Now we know how to switch from server core mode to server GUI mode. Let’s now look how to switch GUI to Core mode. This is very simple and it doesn’t take much time to achieve this.

Open the command prompt and start the powershell. To uninstall GUI and Server Manager feature, type the command Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Restart.

Note :- If you want only the server manager in the core mode you can skip Server-Gui-Mgmt-Infra from the above command.

Back in time when I had to install additional Windows Components on a 2003 Server the Windows Comopnents Wizard asked me to insert the install disk or point to a folder which contains the install files. In Windows Server 2008 this was changed and all files were copied to the C:\Windows\WinSxS folder so when I decided to install a feature or a role all files were already on the machine. Unfortunately these files cannot be removed but in Windows Server 2012 you have this option to save space, have smaller server footprint, and even satisfy your security officer: this is called features on demand.

Remove install files

On a freshly installed server the WinSxS folder looks like this:

WinSxS folder size

Use Get-WindowsFeature command from a Powershell console to retrieve the current status of roles, role services and features on the server.

How to turn the gui off and on in windows server 2012

Windows features on Server 2012

As you can see in the Install State column, an item can be in the following state:

  • Installed: the role or features is installed, the supporting files are on the server and it actively uses them
  • Available: the role or feature is NOT installed, but the supporting files are on the server ready, in case you want to install/enable that role or feature
  • Removed: the role or feature is NOT installed and the supporting files are removed from the server (you cannot see this on the screenshot above, but believe me Powershell-V2 is in a Removed state by default)

If you install a feature or role from the GUI their status will be Installed rather than Available and if you unistall them they will be in an Available state, not quite surprising. To do the same from Powershell, use the Install-WindowsFeature and the Uninstall-WindowsFeature commands with the appropriate parameters, respectively.

But to change the status of an item to Removed you have to use Uninstall-WindowsFeature with a specific switch parameter, called Remove.

How to turn the gui off and on in windows server 2012

Remove parameter of Uninstall-WindowsFeature

Example: to remove Active Directory Domain Services supporting files use the following Powershell command: Uninstall-WindowsFeature AD-Domain-Services -Remove

How to turn the gui off and on in windows server 2012

Remove role or feature supporting files

To remove all unused role and feature supporting files use the following one-liner:

Get-WindowsFeature | Where-Object | Uninstall-WindowsFeature -Remove

How to turn the gui off and on in windows server 2012

Removing not installed roles and features

Take a look at WinSxS folder size after removing all unused roles and features:

WinSxS folder size

Approximately saved 1,7 GB space.

One more thing about Uninstall-WindowsFeature, be careful with powershell help! I have just noticed the following:

How to turn the gui off and on in windows server 2012

Misleading example

The third example removes any roles or features that are currently INSTALLED on the target server contrary to the message!

Installing removed roles and features

Later you might want to install a role but the files are removed, so have to pay extra attention specifying source folder or image for files otherwise you might end up downloading all of them from the Internet through Windows Update.

Using the GUI

On the Confirmation page of the Add Roles and Features Wizard a message warns you that some source files are missing (the removed files from the WinSxS folder) and you have an additional option at the bottom of the page to be able to specify the source for these files.

Specify an alternate source path

If you have your DVD (image) ready specify the /sources/install.wim file location and an image number in the following format:

Alternate source path

Other options are a network path to a WIM file or a network path to a WinSxS folder.

The last number is the index of an image in a WIM file. To retrieve this use DISM.EXE:

dism.exe /get-imageinfo /imagefile:d:\sources\install.wim

How to turn the gui off and on in windows server 2012

Images in a WIM file

Using Powershell

Not surprisingly you have to use Install-WindowsFeature and use the -Source parameter to accomplish the same with powershell:

Install-WindowsFeature AD-Domain-Services -Source WIM:d:\sources\install.wim:4

How to turn the gui off and on in windows server 2012

Install feature and specifying source

Conclusion

Save space and have smaller server footprint by removing roles and features supporting files: Uninstall-WindowsFeature -remove

During installation specify a source path to copy the files from: Install-WindowsFeature -Source

Use dism to retrieve information about images in a WIM file.

I have only one question: Is it possible to control this during installation and do not copy these files at all?