Friday, September 21, 2012

Even More about Windows Server Core 2012 and GUIs

I’ve written a bit recently about Server Core in Server 2012. But here’s yet more details. In Server 2012, the GUI is an installable feature – one you can add or remove. There are actually three levels of GUI within Server 2012:
  • Full GUI – the full blown Windows Server GUI as we’ve always known it plus the Metro start panel, etc.
  • MinShell – a partial GUI but one that enables you to run things like Server Manager, some control panel applets,MMC consoles and PowerShell ISE.  But no desktop/Metro Shell and no IE.
  • None – The server core GUI as we love it – but with the opportunity to specify PowerShell as the window to open at boot (or when you RDP into it).
This provides a great compromise – you can have the GUI where you need it and remove it when you don’t. I love that – although not all applications will run on MinShell or Server Core itself. You need to check – but increasingly applications are server core friendly! For both MinShell and Server Core, the default is to run CMD.EXE as the default shell – when you logon to a server core box you see CMD.Exe. You can fix that easily enough so that at boot time you get PowerShell instead – a simple registry fix.
As part of the Launch of Server 2012 here in the UK next week, I’ll be presenting a bit on PowerShell and showing some of what it can do. One aspect of the server we are showing is Server Core and I’ll be demoing how easy it is – I wrote a script for that:
Function Set-GUI {  
[Cmdletbinding()]
Param(
[ValidateSet("Full", "MinShell", "None")]
[String] $GuiType = "Full"
)
# Here check what to do and do it Switch ($GuiType) { "Full"     { Add-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
             $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
             Remove-ItemProperty -Path $RegPath -Name Shell -ErrorAction SilentlyContinue –Force
           }
"MinShell" { Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra  # Just in case
             Add-WindowsFeature Server-Gui-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 
           }
"None"     { Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
             $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  }
Default    {"$GuiType unknown - enter Full, MinShell or None"; return
           }
}
# Finally Reboot into new gui mode!
Restart-Computer
} # end of Set-GUI function
This could usefully have been added into the ServerCore Module!

1 comment:

SiKotic said...

You're missing a '}' to close the script block for "None".