0

I need to check if a list of software is installed or not. I don't want list of all software that is installed on the computer, Instead I want a list of only specific software and if it's installed or not. And if that software is not installed then it needs to be installed.

This is what I did, can anyone tell me how to proceed?

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
    Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
    Export-Csv C:"path"

This code is displaying the entire list of software that is installed on a computer. How can I customize it to show only the software that I want and how do I install a software if I find that it is not installed?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Vasuki Ms
  • 29
  • 1
  • 6
  • Possible duplicate of [How can I uninstall an application using PowerShell?](http://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell) – The Bearded Llama Mar 14 '17 at 15:20
  • it is always a good idea to look for an existing question first http://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell – The Bearded Llama Mar 14 '17 at 15:20
  • Well, that script would be static wouldn't it? – Vasuki Ms Mar 14 '17 at 15:21
  • @TheBeardedLlama What if the requirement is in such a way that every time I check for different kinds of software not just the same softwares. In that case what would I do? – Vasuki Ms Mar 14 '17 at 15:23
  • 1
    Then you first need to ask yourself how the script knows what software to look for, and how + where to install it from if not found. Use a loop if checking for more than one. – Deadly-Bagel Mar 14 '17 at 16:19
  • @Deadly-Bagel I know where to install it from, as I have a repository of software's. But Need to do the first part of it that is to check software's if installed or not – Vasuki Ms Mar 14 '17 at 16:55

1 Answers1

0

You could write a parameterized script that would allow you to filter the registry values for particular entries. Of course your script would also need to know which installer to invoke for which filter string.

[CmdletBinding()]
Param(
  [Parameter(Mandatory=$true)]
  [string]$Filter
)

$key = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'

$installers = @{
  'foo' = '\\server\share\some_installer.exe'
  'bar' = '\\server\share\other_installer.msi'
}

$software = Get-ItemProperty "$key\*" |
            Where-Object { $_.DisplayName -like "*$Filter*" }

if (-not $software) {
  $installers.Keys | Where-Object {
    $_ -like "*$Filter*"
  } | ForEach-Object {
    & $installers[$_]
  }
}

Note that unless you only want to check for 32-bit programs you need to handle the 64-bit uninstall key as well (and perhaps the user keys also).

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328