4

Using Windows 10 Pro Version 1909 (Build 18363.476), when I try to run in Powershell (Administrator): Get-Module -ListAvailable -All

I get an access denied to location "C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\BitLocker\BitLocker.psm1" error, so it looks like my PowerShell installation is corrupt.

How can I repair/reinstall it?

11
  • PowerShell 5.1 cannot be "reinstalled" on Windows 10. There is no way to reinstall or uninstall PowerShell 5.1 on Windows 10. Releated: Command Prompt: access denied when run PowerShell
    – Ramhound
    Nov 19, 2019 at 18:58
  • Please edit your question to include the exact build of Windows 10 you are using.
    – Ramhound
    Nov 19, 2019 at 19:03
  • 1
    Are you running Windows 10 Home or Windows 10 Professional?
    – Ramhound
    Nov 19, 2019 at 19:30
  • 1
    Why do you think powershell is the issue rather than authority to access the bitlocker.psm1 file? It would help if you edited in the full results of Get-Module -ListAvailable -All rather than a partial result (although I tried to edit in what you gave). You shouldn't try to guess an answer in your question - just describe the error.
    – lx07
    Nov 19, 2019 at 19:46
  • 1
    @JW0914 - Because I know the version of the powershell.exe executable is the same version as that of Windows kernel. Since I also know every version of Windows 8+ include PowerShell 5.1, I know that based on that fact, it cannot possible be any other version of PowerShell. Which means the version of PowerShell the author is attempting to use is PowerShell 5.1. Why are so many people pushing back on the statements about .NET Framework and PowerShell 5.1?
    – Ramhound
    Nov 19, 2019 at 22:13

3 Answers 3

2

While there is no offical way to repair PowerShell in Windows 10, here is how I did it:

  • I just downloaded a VM image of Windows 10,
  • zipped C:\WINDOWS\system32\WindowsPowerShell\v1.0
  • saved permissions of the v1.0 folder into a file using icacls
  • extracted the zip on the machine with the broken powershell
  • restored file permissions with icacls

Now it works again.

1
  • 1
    There is a way to repair all Windows OS system files, which I explain in this comment under your question. Windows includes a backup of every system file contained within %WinDir% in the Component Store (%WinDir%\WinSxS). The DISM command in the comment verifies the backups in WinSxS against known good copies on the Windows Update servers, replacing any with a hash mismatch. SFC then compares all Windows system files in %WinDir% against the known good copies in WinSxS.
    – JW0914
    Nov 20, 2019 at 1:18
2

PowerShell is an integral part of Windows 10 and cannot be uninstalled.

What can be done is:

  • Download .NET Framework and re-install the latest version.
    (Note: Reinstalling .Net is inconsistent. Windows will not agree to reinstall a version over itself, only over an older version. In some cases there will be an option to uninstall the latest .Net version and return to to an earlier version, but not in most cases.)

  • Reset all Windows components to a known state by an offline In-place Upgrade, by "upgrading" Windows to itself (or to the latest version). This is equivalent to a major Windows update so take the same precautions. See the article
    Repair Install of Windows 10 with an In-place Upgrade.

7
  • .NET Framework 4.8 cannot be reinstalled on Windows 10 version 1909.
    – Ramhound
    Nov 19, 2019 at 20:02
  • @Ramhound: I'm not yet on it. Why is that?
    – harrymc
    Nov 19, 2019 at 20:09
  • The version of .NET that is included with Windows 8+ cannot be reinstalled. You can upgrade whatever version that might be, and then uninstall that version, but you would end up with the version that was originally installed. Only .NET Framework 3.5 can be removed from Windows 8+
    – Ramhound
    Nov 19, 2019 at 20:38
  • @Ramhound: .Net 4.8 in Programs and Features has an Uninstall option. I wonder if it will then revert to an earlier version so that 4.8 can be reinstalled, although I didn't try. Did you?
    – harrymc
    Nov 19, 2019 at 21:00
  • I know for a fact .NET Framework 4.8 cannot be uninstalled on 1903 and 1909. If you are able to uninstall .NET Framework 4.8 it means you are not running one of those versions.
    – Ramhound
    Nov 19, 2019 at 21:02
1

As an attempt to repair, you can disable and re-enable Windows PowerShell. See this post on Microsoft's forums. (Edit: Per Ramhound's comments, note that this is (at best) unlikely to help. This does not uninstall or entirely disable all versions of Windows PowerShell)

If that doesn't work, you can attempt to repair/reset/resinstall Windows. Note that your files and installed software will be affected by these options.

However (since you just said "PowerShell" and not explicitly "Windows PowerShell"), depending on your situation, you may wish instead to abandon Windows PowerShell and switch to PowerShell Core. (If so, you'll likely want to disable Windows Powershell) This may be preferable to resinstalling/resetting Windows, and this is actually Microsoft's prescribed solution for those who want the newer versions of PowerShell available; see this Microsoft docs page.

Here is Microsoft's page on installing PowerShell Core. Here is a 3rd party guide, written in 2019.

6
  • PowerShell 5.1 cannot be disabled, uninstalled, or repaired on Windows 10.
    – Ramhound
    Nov 19, 2019 at 20:01
  • Windows PowerShell 2.0 is an optional Windows feature still integrated into Windows 10. Per the explanation I linked, if you run optionalfeatures.exe you are able to disable/enable it. You are correct that this is not identical to entirely disabling Powershell 5.1 If you have some particular information as to the specific error mentioned in the question, you should include that info in your answer.
    – JCD
    Nov 19, 2019 at 20:32
  • 1
    Are you positive the version of PowerShell that could be removed can even be installed on Windows 8+? Based on my personal experience I don't believe that to be the case.
    – Ramhound
    Nov 19, 2019 at 20:39
  • 1
    Based on the version of the executable in that location on my system, I can confirm the version of PowerShell the author is using, must be PowerShell 5.1 which means it cannot be reinstalled.
    – Ramhound
    Nov 19, 2019 at 21:04
  • 2
    "Repair/Reset/Reinstall" is the wrong advice, as there's no justification for it. Windows comes with two native binaries, DISM and SFC, for repairing Windows via the OS system file backups, kept in %WinDir%\WinSxS, where DISM should always be run prior to SFC due to the latter being dependent on the data the former is verifying. Commands, issued in sequence listed: dism /online /cleanup-image /restorehealth (requires an internet connection) > sfc /scannow. If /restorehealth fails, re-run after: dism /online /cleanup-image /startcomponentcleanup
    – JW0914
    Nov 19, 2019 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .