powershellinstallation7zip

How to check if 7zip is installed with powershell (My method fails...)


So I'm writing a Powershell script part of which should istall 7zip if it's not installed yet. While writing, I didn't have 7zip on my computer yet, so I was testing the code for Opera web browser (which I obviously had) with this line of code:

if((Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall* | where {$_.displayName -match "opera"}) -eq $null)

This yielded good results.But after I finally installed 7zip and used the same code (replaced "opera" with "7zip") I got nothing - meaning the Get-ItemProperty doesn't list 7zip at all (even though in control panel "Add/Remove Programs" you can see 7zip on the program list)

Any ideas how to check for 7zip being installed in some other way?


Solution

  • This could help:

    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | ?{$_.DisplayName -like "7-Zip*"}