Thursday, July 05, 2012

Making PowerShell the Default Shell in Server 2012 Server Core

Server Core, in Windows Server 2012, is a much improved version of this installation option, first introduced in Windows Server 2008. At the time Server Core was first introduced, it made sense to make CMD.EXE the default shell. Heck – PowerShell could not even run in that environment. But times move on and in Windows Server 2012, Microsoft install PowerShell by default in Server Core. But the legacy of CMD.EXE still remains – at least by default
.
Turns out it’s just a registry setting to tell Winlogon what shell to start-up at boot time. Thanks to a post by Jeff Hicks, I knew where in the registry the key was, and thanks to James O’Neill, I knew what to put in the value! Setting it is then remarkably easy:

$RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Set-ItemProperty -Confirm  -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable'
Restart-Computer

After rebooting – you have PowerShell as your default shell in Server Core. If you are brave, you could just even the –Confirm from the Set-ItemProperty!

7 comments:

Unknown said...

Thanks for the tip, too bad Microsoft did not made this default...

Unknown said...

Thanks! Too bad Microsoft has not made this default...

Anonymous said...

I just tried this and it worked (thanks!) but I did notice that it was not necessary to reboot. The only thing I did different was to just run regedit and make the changes there.

Thomas Lee said...

@Anthony Burton

No - you do not need to reboot, you could just logoff and logon again to see the new shell. Fair point!

Changing via Regedit means using the GUI. Yuck!

Erik Nettekoven said...

Good job! But I would replace Reboot-Computer with Restart-Computer.

Thomas Lee said...

Eric,

Nice catch. Reboot-Computer is a very old Function of mine. You are right, and the article has been updated.

Thanks.

Stephen Owen said...

Do this, and then set your default profile to launch this sweet ASCII Message of the day prompt.

https://github.com/michalmillar/ps-motd