Tuesday, September 18, 2012

More on PowerShell on Server Core

PowerShell and Server Core – Server 2008 R2 and 2012

in July, I wrote a few articles on PowerShell in Server core (here, here, and here). There were two key points noted in those articles. First, Server Core in Server 2012 has a removable GUI – you can add it or remove it! Secondly, in Server Core in Server 2012, by default, the system starts up running CMD.EXE, not PowerShell, although there’s a simple registry hack that enables you to run PowerShell instead.I’ve been playing with this a bit and have discovered a few additional things about Server Core and PowerShell.

Adding PowerShell v3 to Server 2008 R2 Server Core

The first interesting thing I’ve found is that you can add PowerShell V3 to Server 2008 R2 Server Core. However, to do that, you need to add the .NET Framework 4.0 to your server core system. Go to the Microsoft Download centre and download the Microsoft .NET Framework 4 (Standalone Installer for Server Core. Your Server Core installation needs to be running SP1 or higher. Read the instructions carefully!

Adding GUI to Server Core – Which Shell to Run

In one recent article, I noted how you could add and remove the GUI from Server Core. I’ve written two functions (Enable-GUI and Disable-GUI) that convert between the two GUI modes. I’ve tested these functions pretty thoroughly and the adding and removing of the GUI is straightforward, albeit on the slow side.

One thing I found is that if I first set PowerShell as the default shell (see here), then add the GUI, when Windows Server 2012 restarts, you have the GUI, but the shell itself doesn’t start – PowerShell runs as the default shell!  It took me a few minutes to work out what was going on. A very simple workaround is to remove the Shell default value from the Registry before rebooting. The code to add the full GUI back to Server core now looks like this:

Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source d:\sources\sxs
$RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Remove-ItemProperty -Confirm -Path $RegPath -Name Shell -ErrorAction SilentlyContinue

To get the full scripts see here (for Enable-GUI) and here (Disable-GUI).

1 comment:

James Stephan said...

If you are impartial and not full of the microsoft coo-laid. I propose the you recommend VT technologies www.vtutilities.com VT Utilities, free for 90
days and what I have observered it is 10 times more the product of the free 5nine product which you can unlock the full potential for $159. According to Vt Tech it is still in beta but will be availble to purchase for the $120 price point. Also check out my blog
stephanco.blogspot.com about how I have created a start menu of sorts with a free thumb drive app launcher and yes I have even gotten a free file manager, ftp client and MSTSC or rdp to work from the desktop. I feel ct that powershell is not easy to use and that a third party GUI is way cheaper than buying a MS product lic. Just trying to get the word out that are alternatives to making core server 2012 an easy and managable product on the cheap. However there is something to be said for 5nines free v2v software. It converts the vmware vm to a hyper-v vm very well, you do have to power off the vm first and when it creates the hyper-v vm you have to add the vdh drive to the vm and a dvd if you wnat one but otherwise it works very well. Better than the free converter from microsoft and with much hassle. Let me know what you think of my blog and my findings, feel free to use anything I write as I want the world to know what can be done without doing too
much in powershell.

NOTE teh real free core server really has no GUI the posting about does not work on the release free core server 2012.