Introduction
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.
Then run:
Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

Once installed, you need to restart the server. Use this command:
Restart-Computer
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.


To solve the error, follow these steps:
Start by creating a mount directory (i.e C:\Mount), by opening a command prompt:
mkdir c:\mount
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
dism /get-wiminfo /wimfile:d:\sources\install.wim

Mount the WIM file:
dism /mount-wim /wimfile: d:\sources\install.wim /Index:3 /mountdir:C:\Mount\ /readonly

Install and specify the source:
Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source C:\Mount\Windows\SXS

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

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.

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


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.

Removing the GUI from a full installation, using Powershell:
Enter this command:
Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra



References
Related posts
- Install .NET Framework 3.5 using DISM and other methods
- What is Hyper-V Server 2012, and how do I install and administer it?
Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
fails..
success:false
restart needed:no
what to do??
had internet connection
Did you run Powershell as elevated? (Run as Administrator)
I think the problem is at your section Install and specify the source: One screenshot has the source as c:\mount\windows\sxs while the other has the correct source as c:\mount\windows\winsxs
Hi Daniel,
thanks for your article. Don’t know if it will work yet, it is running as I type.
But could you please listen to Derricks remark. If you are lazy, like me, and cut ‘n paste the command line using SXS instead of WinSxS you are in for a long 68% wait again.
Jan
P.S. it is still at 68% 🙁 . Guess I wait until I click Post.
P.P.S. 🙁 Still nog go. And this only because suddenly I couldn’t remotely manage my RRAS server after the last updates what a mess. I have now rebuilt a server with GUI from scratch.
Sometimes I really want to switch to Linux completely.
Nice blog, perfect!
Above steps worked in my case. Thank you.
Hi, I cannot deselect User Interfaces and Infrastructure, it is not allowing me too. Using Windows Server 2012 Standard Edition.
Please help
Great blog entry! Helped me a lot and saved me hours of precious time 😉
When this manual doesn’t work and you are getting the error: 0x800f0906 you will need to uninstall all hotfixes – unless you know which one is causing this (run PS commands “get-hotfix” & “wusa /uninstall /norestart /kb:2887595” for each update or scrip it if you have powershell skills)
Mounted image as suggested in this manual will be seen as outdated by windows if you patched server core installation. The it will try to contact windows update to get newer files but it will fail even though I had internet connection.
Once I uninstalled patches the core 2 GUI as suggested above worked.
Hi,
Nice article.
you need to make change in the code you written as it has 2 issues.
1- index 3 should be 4
2- after /wimfile: you do not need an space.
so the correct one is:
dism /mount-wim /wimfile:d:\sources\install.wim /Index:4 /mountdir:C:\Mount\ /readonly
Instead if mounting the WIM, it is quicker to specify it directly as the source of the operation. Assuming your CD-ROM is in D: and you want Datacenter (i.e., image 4), you can use Install-WindowsFeature Server-GUI-Shell, Server-GUI-Mgmt-Infra -Source wim:D:\sources\install.wim:4
This is a powershell script that I came up with that seems to work pretty well at removing hotfixes.
del c:\hotfix*.txt
get-hotfix | fl hotfixid > c:\hotfixfl.txt
(get-content c:\hotfixfl.txt) |
Foreach-object {$_ -replace “hotfixid : “, “”} |
Foreach-object {$_ -replace “kb”, “KB:”} |
Set-content c:\hotfix.txt
$hotfixes = cat c:\hotfix.txt
foreach ($hotfix in $hotfixes)
{
wusa /uninstall /norestart /quiet /$hotfix
# Wait for wusa.exe to finish and exit (wusa.exe actually leverages
# TrustedInstaller.exe, so you won’t see much activity within the wusa process)
while (@(Get-Process wusa -ErrorAction SilentlyContinue).Count -ne 0)
{
Start-Sleep 1
Write-Host “Waiting for update removal $hotfix to finish …”
}
}
Hi all can any one give full details of windows2012 server instalattion with all softwares and maintiness…iam new for windows2012 server please give best guidens.
Thankyou..
ty so much for this article
Just one thing I think the from window server 2012 R2 and above the SxS have been renamed to WinSxS
So the last statement would be
Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source C:\Mount\Windows\WinSxS
You can make it a lot easier without having to manually mount the wim file.
Dism /online /enable-feature /featurename:ServerCore-FullServer /featurename:Server-Gui-Shell /featurename:Server-Gui-Mgmt /source:wim:D:\sources\install.wim:2
D being the DVD-ROM drive where your Windows 2012 R2 ISO is mounted.
Keep in mind, once you install Windows updates, you can no longer run this command successfully. You have to create a custom ISO with the exact updates you have installed on your server for this to work.
Great article for Server 2012. Thank you so much.