Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion Mysterious-MessyCode.ps1
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
$Uninstallers = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*;($Uninstallers|% {$a=$_;Get-ItemProperty -name UninstallString -Path "$($a.name.replace('HKEY_LOCAL_MACHINE','HKLM:'))" -ErrorAction SilentlyContinue|? {(Get-ItemProperty -name DisplayName -Path $a.name.replace('HKEY_LOCAL_MACHINE','HKLM:')).DisplayName -like '*Carbon*'}}).UninstallString
function Delete-Things {

$app = Read-Host -Prompt "What do you want to nuke?"
$app = "*" + $app + "*"

$UninstallPaths = Get-ChildItem -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Get-ItemProperty |
Where-Object {$_.DisplayName -like $app} |
Select-Object -Property DisplayName, UninstallString, QuietUninstallString

if ($UninstallPaths.count -eq 0){
Write-Output "No results found. Try again."
return
}

Write-Host ($UninstallPaths.count.ToString() + " results found.")

ForEach($deleteThis in $UninstallPaths){
$confirm = Read-Host -Prompt ("Do you want to remove " + $deleteThis.DisplayName + "? (Y/N)")

if ($confirm.ToUpper() -ne "Y") { continue }

if ($deleteThis.QuietUninstallString.Length -gt 0) {
$uninstStr = $deleteThis.QuietUninstallString
}
elseif ($deleteThis.UninstallString -like "msiexec*") {
$uninstStr = $deleteThis.UninstallString + " /qn /norestart"

} else {
$uninstStr = $deleteThis.UninstallString
}

Write-Host $uninstStr
& cmd /c $uninstStr
}
}