Dec 14 2023 05:26 AM
Hello, I want to uninstall the ccleaner program on several computers. I wanted to know from Intune how this could be done? On future occasions I want to uninstall other programs, I have seen a detection and correction script that is the following but it does nothing.
$Name = 'Ccleaner'
if ($null -eq (Get-AppxPackage -Name $Name)) {
Write-Host "Ccleaner is not installed"
exit 0
} Else {
Write-Host "Ccleaner is installed"
Exit 1
}
---------------------
$Name = 'Ccleaner'
try{
Get-AppxPackage -Name $Name | Remove-AppxPackage -ErrorAction stop
Write-Host "ccleaner successfully removed"
}catch{
Write-Error "Error removing Ccleaner"
}
thank you
Dec 15 2023 03:38 AM
Hello @hugo566788
Welcome to the Microsoft community, my name is Recep I'll be happy to help you today.
Instead, you can use the following script to uninstall CCleaner through PowerShell:
$ProgramName = 'CCleaner'
$uninstallString = Get-ItemProperty -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" |
Where-Object { $_.DisplayName -eq $ProgramName } |
Select-Object -ExpandProperty UninstallString
if ($uninstallString -ne $null) {
try {
Write-Host "Uninstalling $ProgramName..."
Start-Process "msiexec.exe" -ArgumentList "/x $uninstallString /qn" -Wait
Write-Host "$ProgramName successfully uninstalled."
} catch {
Write-Error "Error uninstalling $ProgramName: $_"
}
} else {
Write-Host "$ProgramName is not installed."
}
This script uses the registry to find the uninstall string for CCleaner and then executes the uninstallation silently using msiexec.exe. Please make sure to test this script in a controlled environment before deploying it to a larger number of devices.
If I have answered your question, please mark your post as Solved If you like my response, please give it a Like Appreciate your Kudos! Proud to contribute! :) |