Monday, 2 April 2018

windows server 2012 went to CORE mode opening CMD and lost GUI suddenly(by uninstalling some inbuilt features)

 



Procedure to recover GUI in windows 2012 and 2012R2:
Windows Server 2012 includes .NET Framework 4.5 and Windows Server 2012 R2 includes .NET Framework 4.5.1. The .NET Framework provides a comprehensive and consistent programming model to build and run applications (including Roles and Features) that are built for various platforms. Windows Explorer (Graphical Shell), Server Manager, Windows PowerShell, IIS, ASP .NET, Hyper-V, etc, are all dependent on .NET Framework. Since there are multiple OS components dependent on .Net Framework, this feature is installed by default. Therefore, you do not have to install it separately.
It is not recommended to uninstall .NET Framework. In some given circumstances, there may be a requirement to remove/re-install .Net Framework on Windows Server 2012/2012 R2.
When you uncheck the .NET Framework 4.5 checkbox in the Remove Roles/Features Wizard of Server Manager, Windows will check all roles/features that may also be installed as it would need to be removed as well.. If there are other roles or features dependent on .NET Framework, those would be listed in this additional window.
it will leave the server installed in Core and you will be able to get the command prompt only.
For Example:
If you read through the list, the components that are affected by this removal are listed as follows:
  1. .NET Framework 4.5 Features
  2. RSAT (Remote Administration Assessment Toolkit) which includes Hyper-V Management tools and Hyper-V GUI,
  3. User interfaces and Infrastructure, which includes Graphical Management Tools and Infrastructure Server Graphical Shell (Full Shell and min Shell),
  4. PowerShell which will remove complete PowerShell 4.0 and ISE
The list of components may differ depending upon the Roles and Features installed on the Server machine.
How to recover from this situation and to bring back the power shell, .net feature and UI in 2012, 2012U1
As stated earlier, this will leave the server without a graphical shell for user interaction. Only the command prompt will be available post reboot.
If you get into this situation, run the below commands in the Server Core’s command prompt window to help you recover:
i) Run the below commands one by one
DISM.exe /Online /enable-feature /featurename:NetFx4 /all
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all
ii) Reboot the server
iii) To restore the GUI need to run the PowerShell commands. Below procedure how to open PowerShell prompt in server core’s command prompt
a) To begin, press CTRL-ALT-Del and select Task Manager from the list
b) Once Task Manager Opens select File and Run new task
c) You should now see the Create new task menu, type PowerShell.exe and select OK (or) in CMD type start powershell
d) PowerShell prompt should now be open
iv) Run the below commands on the PowerShell prompt
Install-WindowsFeature Server-Gui-Shell
Install-WindowsFeature Server-Gui-Mgmt-Infra
Once the GUI Shell is installed, you will need to restart the server with the following command:shutdown -r -t 0
v)if you get error like component store corrupted then we need to repair DISM store
 Dism /Online /Cleanup-Image /CheckHealth
 it will show DISM store corrupted
then we need to repair that by below command
 Dism /Online /Cleanup-Image /RestoreHealth
if this step also fails then we need to copy sources folder from windows server 2012 iso file to local drive or mount as DVD drive
Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:Full Path to sources/ install.wim file:<Index Number>

OR

(To prevent DISM from using Windows Update for online images)
 Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:Full Path to sources/install.wim file:<Index Number> /limitaccess

 Substitute <Index Number> in the command below with the actual index number (ex: "1") for the edition (ex: "Pro") you want details about from step 6A above.
note: if you copy sources folder to c drive is better option than from a cd drive iso file.(use xcopy /h /c /k /e /r /y d:\sources c:\sources to copy from d drive to c drive

For example:

 Dism /Online /Cleanup-Image /RestoreHealth /Source:wim:C:\sources\install.wim:1 /limitaccess

Click image for larger version. 

Name: DISM_RestoreHealth_wim_sources.png 
Views: 4849 
Size: 23.8 KB 
ID: 23329
in my case index number 2 worked for me
after that try installing gui commands

No comments:
Write comments