There might be a chance while installation of Microsoft Windows Server setup, You might have overlooked the operating systems menus while setup installation and selected default Windows Server 2012 R2 standard (Server Core installation), first option from the list and click next or press enter. This installs windows 2012 R2 standard core OS by default, and no GUI available. It might be hard some guys who use only GUI to manage and configure Windows severs. Rerunning complete setup again takes time, instead with few commands we can switch from Windows 2012 R2 core to GUI easily even after complete installation. Same steps can be run on Windows Server 2016, I didn't find any difference.
Once logged into the Microsoft Windows 2012 R2 Core, by default CMD.exe will be open and visible, run below command to open another powershell console on the core.
I have Windows 2012 R2 OS DVD or ISO already mounted on the server, to know which drive is of the CDROM, run below command.
Get-PSDrive -PSProvider FileSystem
It shows all the available local drives on the server, here is my D drive is 4.24 GB, and for sure it is the OS DVD/ISO. to check and confirm run dir command on D: and verify the contents. In most cases in fresh installations D drive is always CDROM Drive.
Running Get-WindowsImage -Imagepath D:\sources\Install.wim will show the Images inside the OS ISO, As I have installed Standard version of core, I will use Index 2 to convert it by running below command.
Install-WindowsFeature server-gui-shell, server-gui-mgmt-infra -restart -source wim:D:\sources\install.wim:2
Setup will start installing 2 new features, Graphical Management Tools infrastructure and Server Graphical Shell. Once they are completed server will restart automatically, and you will see GUI based Windows 2012 R2 Operating system once rebooted.
On contrary to Converting from Core to GUI, Here in this another tutorial I will switch from GUI to Core, Open Server Manager, under Manage tab, click Remove Roles and Features,
De-Select check box for two features Graphical Management Tools infrastructure and Server Graphical Shell under User interfaces and Infrastructure. click Next.
Confirm the role removal, you can click restart server automatically if required and press button remove. Once server is restarted GUI is gone and only Windows Core exist.
Same process can be achieved from Powershell as well, by running Get-WindowsFeature cmdlet, Once run It show entire features list by which are installed, by scrolling down find the User-Interfaces-Infra and subfeatures. run below one-liner command, to remove them.
Remove-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell -Restart