How to Uninstall Windows PowerShell

Posted on March 20, 2015 by Tim Warner in PowerShell with 0 Comments

Hey, everyone! I captured your attention with that article title, didn’t I? If you’re the Windows geek I am, you probably thought, “Hey–I thought that Windows PowerShell was a core part of the operating system and can’t be removed. Besides, why would I WANT to remove PowerShell?”

Both are reasonable points. Before we get into the details, let me cut to the chase and give you my understanding of how PowerShell removal works:

  • PowerShell v2 is our baseline PowerShell version and cannot be uninstalled without damaging the integrity of Windows.
  • We can add or remove PowerShell v2 support from Windows 8.1 and Windows Server 2012 R2.
  • We can downgrade a manually upgraded PowerShell version by removing the corresponding Windows Management Framework (WMF) package.

As we both know, Windows XP is a a dead operating system. Therefore, I’ll just say for trivia¬†and¬†historical purposes that you can in fact completely remove Windows PowerShell v1 from XP.

Supposedly you could remove Windows PowerShell v2 from Windows Server 2008 RTM by going through Server Manager. However, there’s no Windows PowerShell runtime entry in the Add Features Wizard in Windows Server 2008 R2, as shown in Figure 1.

Figure 1: We can load or unload the ISE, but we can't remove Windows PowerShell v2 from Windows Server 2008 R2. (Image: Tim Warner)

Figure 1: We can load or unload the ISE, but we can’t remove Windows PowerShell v2 from Windows Server 2008 R2. (Image: Tim Warner)

I checked in Windows 7 SP1 and verified that we can’t uninstall Windows PowerShell v2 from the Windows Features dialog box in Control Panel.

If ever you’re wondering what version of the PowerShell runtime you’re currently working with, open a PowerShell console session and access the PSVersion property of the $PSVersionTable automatic variable like so:

Managing PowerShell v2 Coexistence

Because the Windows PowerShell team understands that many Windows systems administrators built scripts in PowerShell v2 that work just fine, thank you very much, they gave us the ability to enable or disable v2 support in Windows Server 2012 R2 and Windows 8.

In Windows Server 2012 R2, fire up an elevated console prompt and let’s see what’s available:

Thus, we can enable the Windows PowerShell v2 engine at any time:

To start a PowerShell v2, session, let’s back out of our current session and invoke the good ol’ cmd.exe shell:

Now we’ll start PowerShell v2 by using a special parameter and verify installation:

Of course, we don’t have Get-WindowsFeature in Windows 8.1, so we’ll instead type the following at a Run or Cmd prompt to open the Windows Features dialog directly:

As shown in Figure 2, we can use the GUI to enable or disable Windows PowerShell v2. We use the same -version 2.0 parameter to invoke a v2 session.

Enable or disable the Windows PowerShell v2 engine in Windows 8.1. (Image: Tim Warner)

Enable or disable the Windows PowerShell v2 engine in Windows 8.1. (Image: Tim Warner)


Downgrading an Installed Windows PowerShell Version

Next, we’ll tackle the question of how we can roll back a newer PowerShell version that we installed on our server or client systems. We understand that each PowerShell version is tied to a particular .NET Framework version, and sometimes an innocent PowerShell version upgrade can break functionality.

Windows Server 2012 R2 and Windows 8.1 both have PowerShell v4 installed by default. Because v4 is the “latest and greatest” release version, we’ll turn our attention to Windows Server 2008 R2 and Windows 7.

On my Windows Server 2008 R2 test server, I went to the Microsoft Download Center and downloaded the Windows Management Framework 4.0 bits. Note that WMF packages use the Microsoft Update .msu file type, and that the packages are associated with a Microsoft Knowledge Base (KB) identifier. My WMF 4.0 package, for instance was named:

The .NET Framework Gotcha

Windows PowerShell v4 relies upon the .NET Framework 4.5. If you don’t have this .NET Framework version installed, the WMF installation completes without errors, but you won’t have Windows PowerShell v4, mark my words on that one.

Before you install WMF 4, download and install .NET Framework 4.5 and retry the WMF installation. You’ll need to reboot after installing WMF 4.0.

You should also know that a PowerShell version upgrade clobbers the previous version. This makes sense when you understand that newer PowerShell features may require a new copy of the ISE, replacement Windows Remote Management (WinRM) bits, and so forth.

The PowerShell version upgrade process works the very same way on Windows 7 SP1 systems.

Performing the Downgrade

Somewhat surprisingly, we can remove our WMF/PowerShell runtime from an elevated PowerShell console session! First, let’s locate the correct WMF install package by referencing its KB ID:

Now for the honkin’ long uninstallation string:

I’ll summarize each part of the preceding for you now:

  • /c: Instructs cmd.exe to carry out the following command and terminate
  • wusa.exe: Windows Update Standalone Installer
  • /KB: Note that we supply only the number here, not the KB prefix

Sure enough, my Windows Server 2008 R2 system is back to baseline:

Again, this downgrade process works identically in Windows 7 SP1.


PowerShell Uninstall Takeaways

So what have we learned? Number one, we recognize that especially going forward from Windows 7 and Windows Server 2008 R2, PowerShell is indeed a core OS component and will be ever-present in much the same way that the .NET Framework is.

We also learned how to selectively enable or disable PowerShell v2 support, which is sometimes useful for full backward compatibility with your scripts.

Finally, we now understand how to both upgrade and downgrade PowerShell versions by managing the WMF Windows Installer packages. I hope you found this article helpful–take care!


Tagged with