top of page
Search

(177) Microsoft Intune - Remove previous versions ASP.NetCore

  • Writer: Mr B SOE way
    Mr B SOE way
  • Aug 29
  • 1 min read

Updated: Aug 30

Had this issue with a customer who reported having issues with ASP.NetCore 8.0.11 showing up in Tenable, where the current installed is ASP.NetCore Runtime 8.0.18 where somehow it tracks the file path showing up like this:


ree

As I have a 'PowerShell' script that has a 'Uninstall script' which is:

#Uninstall ASP.NETCore Runtime 8.0.11 (x86)
$Status = (Start-Process -FilePath ".\aspnetcore-runtime-8.0.11-win-x86.exe" -ArgumentList "/Uninstall /Quiet /Norestart" -Wait).ExitCode

Which does uninstall the application on the device, which should also remove the folders in this path: C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App. Unfortunately that wasn't the case which left all previous folder versions sitting here:

ree


Then in Program Features - Programs it shows this

ree


Anything 'Microsoft ASP.NetCore 8.0.18 and higher' would reside in C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App, in this case I wrapped it up as a win32 app:


# Create a tag file just so Intune knows this was installed
    if (-not (Test-Path "$($env:ProgramData)\MrB\NetCore")) {
        Mkdir "$($env:ProgramData)\MrB\NetCore"
    }
    Set-Content -Path "$($env:ProgramData)\Devicie\MrB\NetCore.ps1.tag" -Value "Installed"


#Remove Microsoft.NETCore.App
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.16" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.32" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.35" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\8.0.11" -Recurse -Force -Confirm:$false

#Remove Microsoft.AspNetcore.App
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\6.0.16" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\6.0.32" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\6.0.35" -Recurse -Force -Confirm:$false
Remove-Item -Path "C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\8.0.11" -Recurse -Force -Confirm:$false
if (test-path "C:\ProgramData\MrB\NetCore\NetCore.ps1.tag"){"Installed"} 

Ensure to run it as "System" context to get it removed, once deployed to the devices group, this will remove all the previous folder versions:

ree

 
 
 

Comments


bottom of page