Uninstall Tool - .NET

can we get this scripted in ? where we can remove the versions from multiple machines…?

Does the uninstall script included on the globals not do the trick?

@Matt_Blaker is there a specific .net software we don’t have in global you are trying to remove?
We have a large amount of .NET software in global which use the uninstall script @Bezalu_CTO mentions and appears to work correctly.
Perhaps it would be better if we add a software to global if we are missing a version you are looking for and use the same uninstall script rather than trying to script this uninstall tool.

1 Like

in the end i found this script … just needed to change the version at the top… something we have to do for tenable vulnerabilities. would be nice to have it as a deployment and you can type in the version and off it goes…

$version = ‘3.1.32’
$softwareName = ‘.Net Core’
$searchString = “$softwareName$version*”
$msiExecPath = Join-Path -Path $env:SystemRoot -ChildPath ‘system32’ | Join-Path -ChildPath ‘msiexec.exe’

function Find-DotNetCoreInstall {
param (
$ver = $version,
$softName = $softwareName
)
$software = @(
‘HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall*’,
‘HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall*’
)
$searchString = “$softwareName$version*”
$allDotNetItems = Get-ItemProperty $software | Where-Object {$_.displayName -like $searchString} | Select-Object DisplayName,DisplayVersion,UninstallString
Write-Output $allDotNetItems
}
$allDotNetItems = Find-DotNetCoreInstall

if($allDotNetItems.count -gt 0) {
Write-Host “Uninstalling $($allDotNetItems.count) components for $softwareName $version”

foreach($item in $allDotNetItems) {
    $uninstallString = $item.UninstallString
    $name = $item.DisplayName
    if ($uninstallString -like "MsiExec.exe *") {
        Write-Host "Uninstalling $name version: $($item.displayVersion)"
        $guid = ([regex]'{[A-Z0-9-]+}').Match($uninstallString).Value

        start-process -FilePath $msiExecPath -ArgumentList @("/x$guid", "/passive", "/quiet", "/norestart", "IGNOREDEPENDENCIES=ALL", "/log `"$env:temp\$($name)_Uninstall_$($version).log`"") -Wait
    } 
    else {
        $filepath = ($uninstallString.Split('/')[0]).replace('"','')
        Write-Host "Uninstalling $name version: $($item.displayVersion)"
        Start-Process -FilePath $filepath -ArgumentList @("/uninstall", "/silent") -Wait
    }
}

}
else {
Write-Host “There are no installed components of $software $version”
exit 0
}

$finalCheck = Find-DotNetCoreInstall
if ($finalCheck.count -eq 0){
Write-Host “All .NET components have been uninstalled”
exit 0
}
else {
Write-Host "Error: NOT ALL COMPONENTS uninstalled! `n $finalCheck "
exit 1
}