12 June 2013

PowerShell: Display all Add/Remove Program Entries with Uninstall String

Posted By: Mick Pletcher - 2:17 PM

Share

& Comment

Here is a script that will display all Add/Remove Program entries with the uninstall string, directly from the x86 and x64 registry keys.

You can download the script from here.

 #*******************************************************************************  
 #      Author: Mick Pletcher  
 #        Date: 12 June 2013  
 #  
 #     Program: Add/Remove Programs  
 # Description: This script will either list all applications in the Add/Remove  
 #              programs, which is pulled from both the registry. On a 64-bit  
 #              machine, it pulls from both the x86 and x64 add/remove programs  
 #              registry entries. You will also have the option to search for  
 #              a specific application.   
 #*******************************************************************************  
 cls

 $Global:OS  

 Function GetOSArchitecture{  
      $Global:OS=Get-WMIObject win32_operatingsystem  
      #$Global:OS.OSArchitecture  
      #Answers: 32-bit, 64-bit  
 }  

 $DisplayOutput = $false  
 GetOSArchitecture  
 [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")  
 [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null  
 $Output = [System.Windows.Forms.MessageBox]::Show("Search for a specific program?" , "Status" , 4)  
 If ($Output -eq "Yes"){  
      $ProgramName = [Microsoft.VisualBasic.Interaction]::InputBox("Enter specific software name:")  
      $ProgramName = "*"+$ProgramName+"*"  
 }  
 If ($Global:OS.OSArchitecture -eq "32-bit"){  
      $RegPath = "HKLM:\software\microsoft\windows\currentversion\uninstall\"  
      $Results = Get-ChildItem $RegPath -Recurse -ErrorAction SilentlyContinue  
      foreach ($item in $Resultsx86){  
           If (($item.GetValue("DisplayName") -ne $null) -and ($item.GetValue("UninstallString") -ne $null)) {  
                Write-Host  
                Write-Host  
             Write-Host "  Software: "$item.GetValue("DisplayName")  
                Write-Host "  Version: "$item.GetValue("DisplayVersion")  
             Write-Host "Uninstaller: "$item.GetValue("UninstallString")  
           }  
      }  
 }  
 If ($Global:OS.OSArchitecture -eq "64-bit"){  
      $RegPathx86 = "HKLM:\software\wow6432node\microsoft\windows\currentversion\uninstall\"  
      $RegPathx64 = "HKLM:\software\microsoft\windows\currentversion\uninstall\"  
      $Resultsx86 = Get-ChildItem $RegPathx86 -Recurse -ErrorAction SilentlyContinue  
      $Resultsx64 = Get-ChildItem $RegPathx64 -Recurse -ErrorAction SilentlyContinue  
      foreach ($item in $Resultsx86){  
           If (($item.GetValue("DisplayName") -ne $null) -and ($item.GetValue("UninstallString") -ne $null)) {  
                If ($Output -eq "Yes"){  
                     If ($item.GetValue("DisplayName") -like $ProgramName){  
                          $DisplayOutput = $true  
                     }  
                }else{  
                     $DisplayOutput = $true  
                }  
                If ($DisplayOutput -eq $true){  
                     Write-Host  
                     Write-Host  
                  Write-Host "  Software: "$item.GetValue("DisplayName")  
                     Write-Host "  Version: "$item.GetValue("DisplayVersion")  
                  Write-Host "Uninstaller: "$item.GetValue("UninstallString")  
                }  
           }  
           $DisplayOutput = $false  
      }  
      $DisplayOutput = $false  
      foreach ($item in $Resultsx64){  
           If (($item.GetValue("DisplayName") -ne $null) -and ($item.GetValue("UninstallString") -ne $null)) {  
                If ($Output -eq "Yes"){  
                     If ($item.GetValue("DisplayName") -like $ProgramName){  
                          $DisplayOutput = $true  
                     }  
                }else{  
                     $DisplayOutput = $true  
                }  
                If ($DisplayOutput -eq $true){  
                     Write-Host  
                     Write-Host  
                  Write-Host "  Software: "$item.GetValue("DisplayName")  
                     Write-Host "  Version: "$item.GetValue("DisplayVersion")  
                  Write-Host "Uninstaller: "$item.GetValue("UninstallString")  
                }  
           }  
           $DisplayOutput = $false  
      }  
 }  

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

1 comments:

  1. This is a good article & good site.Thank you for sharing this article. It is help us following categorize:
    it consulting, retail, manufacturing, CRM, digital supply chain management, Delivering high-quality service for your business applications,
    Solutions for all Industries,
    Getting your applications talking is the key to better business processes,
    Rapid web services solutions for real business problems,
    Understanding Your Data is the Key to Good Decision-Making,
    Web-based Corporate Document Management System,
    Outsourcing Solution,
    Financial and Operations Business Intelligence Solution,

    prologic-corp

    ReplyDelete

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.