Intune proactive remediation to Uninstall Software

Remotely Uninstall

Invoke-Command -Computername $Computers {Get-Package -Name "*SilverLight*" | Uninstall-Package}

Locally Uninstall

Get-Package -Name "*SilverLight*" | Uninstall-Package

Location ( Make sure you are licensed to use ) 

Detect

$SoftwareName = "Silverlight"

$ItemProperties = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where Displayname -like "*$SoftwareName*"


if ($ItemProperties) {
    Write-Host "$SoftwareName found"
    Exit 1
} Else {
    Write-Host "$SoftwareName Not found"
    Exit 0
}


 catch{
    $errMsg = $_.exeption.essage
    Write-Output $errMsg
 }

Remmediate

# MrNetTek
# eddiejackson.net
# 7/15/2022
# free for public use
# free to claim as your own
 
$SoftwareName = "Silverlight"
 
$ItemProperties = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Select-Object DisplayName,UninstallString
 
foreach ($Item in $ItemProperties)
    {
        $DisplayName = $Item.DisplayName
        $UninstallString = $Item.UninstallString
        if($DisplayName -like "*$SoftwareName*")
            {
                Write-Host "$DisplayName : $UninstallString"
                # Output: Microsoft Silverlight : MsiExec.exe /X{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}
                 
                # Always test this on a reference machine, first
                # Sometimes the uninstall string is wrong, right from the vendor
                # If you do run across an invalid uninstall string, fix it
                # and hard code the uninstall string into your script
                # Silverlight was missing the /qn
                cmd.exe /c "$UninstallString /qn"
            }
    }
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...