Forum Discussion
markgardenstate
Oct 22, 2024Copper Contributor
Old .NET versions automatic uninstallation/removal
Hello,
How are you removing old versions of .NET from your devices? Is there a way to automate this?
To better clarify our issue, please see the screenshot below.
We just installed the latest version (6.0.35) for both: .NET Runtime and Desktop Runtime but older 6.0.33 versions are still there.
We need to automate those older versions removal.
I appreciate your response and help.
Thanks,
Mark
- micheleariisSteel Contributor
markgardenstate Hi, you could use a powershell script distributed through Intune.
This script identifies all installed versions of .NET and removes those with versions lower than the one specified in $targetVersion. You can modify this script to suit your needs (for example, to target only specific runtimes such as Desktop Runtime).$targetVersion = "6.0.35"
# Get all installed .NET runtimes
$installedDotNetVersions = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like 'Microsoft .NET*' }
foreach ($dotNetVersion in $installedDotNetVersions) {
if ($dotNetVersion.Version -lt $targetVersion) {
Write-Host "Uninstalling $($dotNetVersion.Name) - Version $($dotNetVersion.Version)"
$dotNetVersion.Uninstall()
}
}
- markgardenstateCopper Contributor