Public/Get-specPublisherInfo.ps1

function Get-specPublisherInfo {
    <#
    .SYNOPSIS
    Retrieves detailed information about installed applications from the registry, filtered by Publisher or DisplayName.
 
    .DESCRIPTION
    The Get-specPublisherInfo function queries the HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall registry path
    to retrieve information about installed applications. The function supports filtering by Publisher or DisplayName.
 
    The search can be an exact match or a "like" search:
    - Exact match: Specify the value without a wildcard (*).
    - "Like" search: Use * as a wildcard to find partial matches.
 
    .PARAMETER PublisherFilter
    Specifies the Publisher name to filter by. The default is Star*, which performs a "like" search for publishers
    that start with "Star". If no wildcard is included, an exact match is performed.
 
    .PARAMETER DisplayNameFilter
    Specifies the DisplayName to filter by. If no wildcard is included, an exact match is performed.
 
    .EXAMPLES
    # Example 1: Search for publishers that start with "Star"
    Get-specPublisherInfo
 
    # Example 2: Perform an exact match for a specific publisher
    Get-specPublisherInfo -PublisherFilter 'StarSoftware Inc.'
 
    # Example 3: Search for applications with "Pro" in their display name
    Get-specPublisherInfo -DisplayNameFilter '*Pro*'
 
    # Example 4: Perform an exact match for a specific application by DisplayName
    Get-specPublisherInfo -DisplayNameFilter 'Star App Pro v1.0'
 
    .OUTPUTS
    PSCustomObject
    Each object contains the following properties:
    - GUID: The unique identifier for the application in the registry.
    - Publisher: The application's publisher.
    - DisplayName: The display name of the application.
    - DisplayVersion: The version of the application.
    - UninstallString: The path to the application's uninstaller.
    - Path: The registry path for the application.
 
    .NOTES
    Author: owen.heaume
    Version: 1.0
    #>


    [CmdletBinding(DefaultParameterSetName = 'PublisherSearch')]
    param (
        # Filter string for Publisher name (used in PublisherSearch parameter set)
        [Parameter(ParameterSetName = 'PublisherSearch')]
        [string]$PublisherFilter = 'Star*',

        # Filter string for DisplayName (used in DisplayNameSearch parameter set)
        [Parameter(ParameterSetName = 'DisplayNameSearch')]
        [string]$DisplayNameFilter
    )

    begin {
        $RegUninstallPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    }

    process {
        # Get all subkeys from the Uninstall path
        gci $RegUninstallPath | % {
            # Get properties of each registry key
            $properties = Get-ItemProperty -Path $_.PSPath -ErrorAction SilentlyContinue

            # Initialize the PSCustomObject for each match
            $psCustomObject = [PSCustomObject]@{
                GUID            = ($properties.PSChildName -split '\\')[-1]
                Publisher       = $properties.Publisher
                DisplayName     = $properties.DisplayName
                DisplayVersion  = $properties.DisplayVersion
                UninstallString = $properties.UninstallString
                Path            = $properties.PSPath
            }

            # Process based on the active parameter set
            switch ($PSCmdlet.ParameterSetName) {
                'PublisherSearch' {
                    if ($properties.Publisher -like $PublisherFilter) {
                        $psCustomObject
                    }
                }
                'DisplayNameSearch' {
                    if ($properties.DisplayName -like $DisplayNameFilter) {
                        $psCustomObject
                    }
                }
            }
        }
    }
}