Zluri Duplicate Agent Removal
unknown
plain_text
a month ago
2.0 kB
17
Indexable
# Get all Zluri applications from both local machine and current user registry $apps = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, ` HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*, ` HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, ` HKCU:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*zluri*" } # If no applications found, exit if (-not $apps) { Write-Host "No Zluri applications found." exit } # Convert to array if single item if ($apps -isnot [array]) { $apps = @($apps) } # Get the latest version $latestVersion = ($apps | Where-Object { $_.DisplayVersion } | Sort-Object { [Version]$_.DisplayVersion } -Descending | Select-Object -First 1).DisplayVersion Write-Host "Latest version found: $latestVersion" # Uninstall all versions except the latest foreach ($app in $apps) { if ($app.DisplayVersion -and $app.UninstallString) { # Skip if this is the latest version if ($app.DisplayVersion -eq $latestVersion) { Write-Host "Skipping latest version $($app.DisplayName) version $($app.DisplayVersion)" continue } # Prepare uninstall command $uninstallCmd = $app.UninstallString -replace "/I", "/X" Write-Host "Uninstalling $($app.DisplayName) version $($app.DisplayVersion)..." try { Start-Process -FilePath "cmd.exe" -ArgumentList "/c $uninstallCmd /quiet /norestart" -Wait Write-Host "Successfully uninstalled $($app.DisplayName) version $($app.DisplayVersion)" } catch { Write-Error "Failed to uninstall $($app.DisplayName) version $($app.DisplayVersion): $_" } } } Write-Host "Uninstallation process completed. Latest version $latestVersion remains installed."
Editor is loading...
Leave a Comment