private/Tests/Test-Install7Zip.ps1

function Test-Install7Zip {
    <#
    .SYNOPSIS
        Returns $true when 7-Zip is installed.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Detection: Uninstall registry — DisplayName like '7-Zip*'.
        Also checks the default install path as a fast path.
 
    Dependencies:
      Executables: 7z.exe
    #>

    [OutputType([bool])]
    param ()

    # Fast path — default install location
    $defaultPaths = @(
        (Join-Path $env:ProgramFiles   '7-Zip\7z.exe'),
        (Join-Path ${env:ProgramFiles(x86)} '7-Zip\7z.exe')
    )
    foreach ($path in $defaultPaths) {
        if (Test-Path -Path $path) { return $true }
    }

    # Registry fallback
    $regPaths = @(
        'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
    )

    foreach ($regPath in $regPaths) {
        $entry = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue |
            Where-Object { $_.PSObject.Properties['DisplayName'] -and $_.DisplayName -like '7-Zip*' } |
            Select-Object -First 1
        if ($entry) { return $true }
    }

    return $false
}