When working with Windows Server 2012 Core Edition, discovering that PowerShell has suddenly vanished after a reboot can be particularly frustrating, especially when remote management tools aren't yet configured. The error message 'powershell' is not recognized as an internal or external command
indicates the shell environment is completely missing.
Since remote administration isn't available, you'll need physical or console access to the server. Log in using the standard command prompt interface.
First, check if PowerShell is actually uninstalled or just not in the PATH:
dism /online /get-features | find "MicrosoftWindowsPowerShell"
If this returns nothing or shows "Disabled" status, we'll need to re-enable it.
The Deployment Image Servicing and Management tool is your best friend here:
dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all
dism /online /enable-feature /featurename:MicrosoftWindowsPowerShellV2 /all
Wait for the operation to complete, then reboot:
shutdown /r /t 0
If DISM doesn't resolve the issue, you can try installing via the Package Manager:
start /w pkgmgr /iu:MicrosoftWindowsPowerShell
start /w pkgmgr /iu:MicrosoftWindowsPowerShellV2
After reboot, verify PowerShell is working:
powershell -command "Get-Host | Select-Object Version"
This should return the installed PowerShell version information.
To avoid this situation recurring:
- Document all installed features using:
dism /online /get-features > features.txt
- Set up remote management as soon as possible
- Consider creating a system restore point before major changes
If immediate PowerShell access is critical and reinstallation fails, you can:
- Copy PowerShell files from another Server 2012 Core installation
- Manually add the PowerShell directory to PATH
- Register the PowerShell .dll files using regsvr32
However, this is not recommended as a permanent solution.
Working with Server Core installations can be tricky, especially when essential components like PowerShell mysteriously vanish after a reboot. This exact situation happened to me recently on a Windows Server 2012 R2 Core installation where PowerShell suddenly became unavailable with the classic error:
'powershell' is not recognized as an internal or external command, operable program, or batch file.
Before attempting reinstallation, let's confirm PowerShell's status. Even without PS, we can use basic command prompt tools:
dism /online /get-features | find "MicrosoftWindowsPowerShell"
If this returns nothing or shows "Disabled" status, we've found our issue. Another check:
reg query "HKLM\SOFTWARE\Microsoft\PowerShell\1" /v Install
The most reliable method I've found is using Deployment Image Servicing and Management (DISM). Here's the step-by-step:
dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all dism /online /enable-feature /featurename:MicrosoftWindowsPowerShellV2 /all
After running these commands, reboot the server:
shutdown /r /t 0
If DISM doesn't work (which sometimes happens with corrupted installations), we can try extracting PowerShell from installation media. Mount your Server 2012 ISO and run:
dism /online /add-package /packagepath:"D:\sources\sxs\microsoft-windows-powershell-client-package~31bf3856ad364e35~amd64~~6.2.9200.16384.mum" dism /online /add-package /packagepath:"D:\sources\sxs\microsoft-windows-powershell-foundation-package~31bf3856ad364e35~amd64~~6.2.9200.16384.mum"
After successful installation and reboot, verify with:
powershell -command "& {$PSVersionTable}"
You should see output similar to:
Name Value ---- ----- PSVersion 3.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.18444 BuildVersion 6.2.9200.16398 PSCompatibleVersions {1.0, 2.0, 3.0} PSRemotingProtocolVersion 2.2
To avoid recurrence, consider these precautions:
# Create a system restore point before major changes wmic.exe /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "Pre-PSInstall", 100, 7 # Export PowerShell registry keys for backup reg export "HKLM\SOFTWARE\Microsoft\PowerShell" powershell_backup.reg