6

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.

5
  • @PimpJuiceIT Thank you for the assistance, I followed your steps but the same error occurs.
    – gommb
    Jan 31, 2019 at 6:24
  • @PimpJuiceIT I tried everything you said and nothing worked. The only thing I couldn't do is look through Event Viewer because when I open it up I get this error MMC cannot initialize the snap-in. I wonder if this could be in any way related to the powershell error.
    – gommb
    Feb 1, 2019 at 20:49
  • @PimpJuiceIT I use Norton
    – gommb
    Feb 1, 2019 at 21:51
  • @PimpJuiceIT After almost a month of searching, I narrowed this down to the Microsoft.NET folder in C:\Windows. I replaced this folder with a friend's Microsoft.NET folder who wasn't having the issue, and powershell suddenly works again.
    – gommb
    Feb 21, 2019 at 2:59
  • Here's a tool here that may have helped too: microsoft.com/en-us/download/details.aspx?id=30135 Feb 21, 2019 at 13:03

1 Answer 1

7

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:

<?xml version="1.0" encoding="UTF-8"?>
<configuration />

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:

%Windows%\Microsoft.NET\Framework\v{version}\CONFIG
%Windows%\Microsoft.NET\Framework64\v{version}\CONFIG

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.

forfiles /P %windows% /S /M machine.config /C "cmd /c if @isdir==FALSE if @fsize EQU 0 echo @path"
5
  • Interesting, and good to know fix!! Jul 7, 2019 at 22:24
  • I tried the minimum required version and it didn't work for me. I noticed I had a file named "machine.config.default". I replaced machine.config with that file and it worked! Mar 6, 2020 at 18:21
  • Where is the machine.config file located? Seach finds several in the \Windows\WinSxS folder but the file can't be edited or deleted.
    – x-x
    Jul 17, 2020 at 6:14
  • I updated the answer with tips for finding the defective machine.config files
    – shawn
    Jul 17, 2020 at 16:07
  • Thanks for the update. However, though my problem appears to be the same, your solution doesn't solve it :( Typical Microsoft garbage...
    – x-x
    Jul 18, 2020 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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