Public/Find-specInstalledProgram.ps1

function Find-specInstalledProgram {
    <#
    .SYNOPSIS
        Find installed programs bysearching the registry.
 
    .DESCRIPTION
        This function searches for installed programs in the Windows registry and can be based on a wildcard search of the program display name.
        It is not case-sensitive any any of the searches.
        It outputs a custom object containing the Displayname, DisplayVersion, Publisher,InstallDate and Uninstall string.
 
    .PARAMETER Name
        Specifies the name of the program to search for. You can use wildcard characters such as '*' for pattern matching.
 
    .EXAMPLE
        Find-specInstalledProgram -Name "NVIDIA PhysX System Software 9.20.0221"
 
        This example searches for programs with the exact display name of "NVIDIA PhysX System Software 9.20.0221".
 
    .EXAMPLE
        Find-specInstalledProgram -Name "Nvidia*"
 
        This example searches for programs with a display name starting with the word "Nvidia".
        It will return all entries found.
 
    .OUTPUTS
        PSCustomObject
 
    .NOTES
        Author: owen.heaume
        Version: 1.0.0 - Initial release
    #>

    [cmdletBinding()]
    param(
        [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
        [string]$Name
    )

    Begin {
        $regPaths = @(
            'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
            'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
        )
    }

    Process {
        foreach ($path in $regPaths) {
            if (Test-Path $path) {
                Get-ChildItem $path | ForEach-Object {
                    $program = Get-ItemProperty $_.PsPath
                    if ($program.DisplayName -like $Name) {
                        [pscustomobject]@{
                            DisplayName     = $program.DisplayName
                            DisplayVersion  = $program.DisplayVersion
                            Publisher       = $program.Publisher
                            InstallDate     = $program.InstallDate
                            UninstallString = $program.UninstallString
                        }
                    }
                }
            }
        }
    }
}