SOLVED: Command Line Uninstall, Reinstall, Repair .NET Framework

After working on a corrupt .NET installation for many hours we placed a call to Microsoft tech support because we could not get around errors like:

This application requires one of the following versions of the .NET Framework v4.0.30319

when launching Azure AD Sync or even Server Manager.

Microsoft Server Tech Support contractor Samson Peng gave us the following commands to uninstall, reinstall and repair .NET that we could not find anywhere on-line.

Of course this process will change in the future with .NET5 and .NET6 but these commands and logic which relate to .NET4 should give you a good starting point.

How To Reinstall .NET Manually

1 – Get Windows Server Installation Media

If you don’t already have an .ISO (or DVD) available, you can download one for free from the Windows Evaluation Center HERE (click WINDOWS SERVER along the top menu bar then select your version).

2 – Mount the Windows Server .ISO or insert the DVD
3 – Command Line Uninstall .NET and Reinstall

Note: If you see an error, just keep going. It is likely that you just don’t the feature in question

Open a PowerShell as an Admin and run each of these commands one by one adjusting the D:\SOURCES path to whatever your ISO is mounted as:

dism /online /disable-feature /featurename:Netfx4 /norestart

dism /online /enable-feature /featureName:Netfx4 /source:wim:D:\sources\Install.wim:4 /limitaccess /norestart /all

dism /online /enable-feature /featureName:MicrosoftWindowsPowerShell /source:wim:D:\sources\Install.wim:4 /limitaccess /norestart /all

dism /online /enable-feature /featureName:Server-Gui-Mgmt /source:wim:D:\sources\Install.wim:4 /limitaccess /norestart /all

dism /online /enable-feature /featureName:Server-Gui-Shell /source:wim:D:\sources\Install.wim:4 /limitaccess /norestart /all

4 – Reboot the server

Open a PowerShell as an Admin and run each of these commands one by one adjusting the D:\SOURCES path to whatever your ISO is mounted as:

Note: If you see an error, just keep going. It is likely that you just don’t the feature in question

DISM.exe /online /enable-feature /all /featurename:NetFx4

DISM.exe /online /enable-feature /all /featurename:MicrosoftWindowsPowerShell

Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

5 – Reboot the server

Now try whatever was failing before.

Thanks Samson!


View Comments

Published by
Ian Matthews

This website uses cookies.