Whenever I try to open Powershell, it just won't open. When I try to open it from the cmd, I get this error:
The shell cannot be started. A failure occurred during initialization:
The type initializer for 'System.Net.ServicePointManager' threw an exception.
Things I have tried:
- opening with administrator
- sfc /scannow which showed no errors
The 32 bit version of powershell still works for some reason if that helps in any way.
Best Answer
I just dealt with this on a client computer. The problem was that the
machine.config
files for .NET Framework 4.x had both been corrupted (they had somehow become zero-length files).Deleting the files is insufficient.
It worked to simply replace the zero length files with the code below, but I used the "known good" versions in order to ensure that there weren't any long-term side-effects.
This is the minimum required content for the
machine.config
files:Replacing these two files with "known good" copies of
machine.config
from the same version resolved this for me and didn't leave me worrying that some unknown issue would crop up later.After fixing or replacing the
machine.config
files a reboot is required.The Windows
machine.config
file is located one of the following folders:There may also be corrupted
machine.config
files for individual applications under their*\mono\{version}
folders, though I would be much more hesitant to replace them without using a copy from the same application and application version on the same platform and CPU architecture.In any case, on Windows, you can find the specific defective files by searching for zero-length files under the Windows folder named
machine.config
. This command will do that for you.