Removing McAfee remnants
1 min readIf your company uses a Security tool to detect vulnerabilities it usually will scan for registry and file locations. McAfee can be a nightmare to uninstall in an enterprise and it leaves behind a registry key and directory often when you uninstall. This script removes those. File location may change. Adjust accordingly. In our environment we run the script out of SCCM to hit all servers.
# Registry key to remove
$registryKey = "HKLM:\Software\McAfee"
$filepath = "C:\windows\Program files\McAfee"
# Check if the registry key exists
if (Test-Path $registryKey) {
# Remove the registry key
Remove-Item -Path $registryKey -Recurse -Force
Write-Host "Registry key '$registryKey' has been removed."
} else {
Write-Host "Registry key '$registryKey' not found."
}
if (Test-Path $filepath) {
Remove-Item -Path $filepath -Recurse -Force
Write-Host "Path '$filepath' has been removed."
} else {
Write-Host "Path '$filepath' not found."
}