Wednesday, August 3, 2016

Automatic Uninstall of Windows Management Framework

Hi folks,

I would love to share with you about an experience I have recently had. I was working on the installation of Exchange 2016 servers on servers running Windows Server 2012 R2. The standard image that I had came with the PowerShell 5.0 with which Exchange 2016 can't work. PowerShell 5.0 comes for Windows 2012 R2 as part of the Windows Management Framework 5.0.

So before installing Exchange 2016 you will need to uninstall it to avoid issues when running EMS. It can be done easily from Windows Control Panel. However there is also an automatic way of uninstalling it.

This method can be useful when you are trying to uninstall it from more than one server or when you are trying to understand any other Windows updates or hotfixes. In the Technet gallery there is a module that allows to perform installation. It can be located here.

After module is downloaded you will need to load it to your PowerShell section and then you will need to execute the Uninstall-OSCHotfix cmdlet with the number of the KB of the update you want to uninstall. In case of the Windows Management Framework it is KB3134758.

In my case script the code looked like something as below. Please note that the path to the PSM1 file may vary.

Import-Module c:\Scripts\UninstallHotFixPowerShell\UninstallHotFix.psm1
Uninstall-OSCHotfix -HotFixID KB3134758

It will look something like this:

After update is uninstalled you will need tor reboot your server for it to take effect. After which you can confirm that you are running PowerShell v4.0 by running the below command:


Finally, I would love to repeat that this module can be used for other updates and hotfixes. All you need is to include the appropriate KB number into your command.