Advertisement
0utsidethebox

uninstall windows registry

Dec 17th, 2024
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Define the value to search for in DisplayName
  2. $searchValue = "vmware" # Replace with the desired value
  3.  
  4. # Define the registry path
  5. $registryPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
  6.  
  7. # Collect results
  8. $results = @()
  9.  
  10. # Recursively search the registry path
  11. Get-ChildItem -Path $registryPath -Recurse | ForEach-Object {
  12.     try {
  13.         # Check if DisplayName exists and matches the search value
  14.         $displayName = (Get-ItemProperty -Path $_.PSPath -ErrorAction Stop).DisplayName
  15.         if ($displayName -like "*$searchValue*") {
  16.             # Retrieve the UninstallString
  17.             $uninstallString = (Get-ItemProperty -Path $_.PSPath -ErrorAction Stop).UninstallString
  18.  
  19.             # Add to results
  20.             $results += [PSCustomObject]@{
  21.                 DisplayName     = $displayName
  22.                 UninstallString = $uninstallString
  23.             }
  24.         }
  25.     } catch {
  26.         # Ignore errors (e.g., keys without DisplayName or UninstallString)
  27.     }
  28. }
  29.  
  30. # Display results as a table
  31. if ($results.Count -gt 0) {
  32.     $results | Format-Table -AutoSize
  33. } else {
  34.     Write-Host "No matching applications found." -ForegroundColor Yellow
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement