Search code examples
powershellwindows-10powershell-5.0powershell-5.1

Windows PowerShell - Microsoft.Powershell.Commands.Utility not found


I first discovered that PowerShell is not working correctly when I open my VisualStudio 2019. The Package Manager Console was not working as you can see below:

`Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Utility because of the following error: Could not load file or assembly 'Microsoft.PowerShell.Commands' or one of its dependencies.`

After I discovered this error i have done different things like: Done all updates available for Visual Studio 2019, all windows 10 updates, searched for the error everywhere but couldn´t find a similar question. Also tryed sfc /scannow.

I first tought it was only a Visual Studio error, but as I searched deeper, I found some suggestions like: Type write-host 'test' into Windows PowerShell, so I did. The error in Powershell.

Not just I can´t run simple commands like write-host 'test', I also can´t run Import-Module Microsoft.PowerShell.Utility to install the missing commands.

Anybody up with an idea that not includes to reinstall windows?

Output of $PSVersionTable:

Name Value
PSVersion 5.1.19041.1023
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1023
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Operating System: Windows 10 Pro Version: 21H1


Solution

  • I still don´t know where the error came from, but I solved the problem by downloading the MediaCreationTool from Microsoft and created an ISO file. After that I startet die Setup.exe from the ISO. I "Reinstalled" Windows 10 with the option to keep my apps and documents. At first place I had an error 0xC1900101 - 0x2000c. I disconnected my dockingstation and tryed it again. Now it run successfully and I can use PowerShell again.