8

In server core, after a restart powershell was all of a sudden not installed, what do I do to reinstall it?

I do not have remote administration set up yet so I cannot use that to re-install it.

'powershell' is not recognized as an internal or external command, operable program, or batch file.

  • Did you verify the binaries are gone? It could be as simple as your %PATH% variable missing/broken. – jscott Sep 22 '12 at 22:51
  • 2
    Yes, the binaries are gone. C:\Windows\System32\WindowsPowershell\v1.0\ was empty – 124597627895789645856485 Sep 22 '12 at 23:43
8

Use the Deployment Image Servicing and Management (DISM.exe) tool to enable PowerShell:

dism.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShellRoot

...or if that's not enough:

dism.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all

  • I did try that, where was no option to install Powershell and enabling remote management did not do anything to install it – 124597627895789645856485 Sep 22 '12 at 23:42
  • Thanks. Although I had to append /all onto the end of the second command. I accidentally removed a feature in 2012's server manager and had to use this to get back on my feet again. After that I followed this guide: telnet25.wordpress.com/2012/09/21/server-core-install-gui – maxp Oct 19 '12 at 11:23
  • I get the error "DISM does not suport servicing Windows PE with the /Online option ??? – Sinaesthetic Sep 27 '14 at 0:59
2
dism.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShellRoot
dism.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all

Say "yes" for reboot.

powershell
Add-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
Shutdown -r -t 0

In server 2012 R2 Use Shutdown /r /t 0

Not the answer you're looking for? Browse other questions tagged or ask your own question.