List installed programs with PowerShell

The function Get-InstalledPrograms will list all programs installed on the local computer and for the current user. Its output should match that of commands such as ms-settings:appsfeatures or %windir%\System32\appwiz.cpl:

function Get-InstalledPrograms {

    [CmdletBinding()]
    param (
        [Parameter()]
        [string]
        $DisplayName
    );

    Set-StrictMode -Off;
    if( -not $DisplayName ) {
        $DisplayName = '*';
    }
    Get-ItemProperty -Path $(
        'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*';
        'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*';
        'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*';
        'HKCU:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*';
    ) -ErrorAction 'SilentlyContinue'
    | Where-Object -Property 'DisplayName' -Like $DisplayName
    | Select-Object -Property 'DisplayName', 'UninstallString', 'ModifyPath'
    | Sort-Object -Property 'DisplayName';
}
Get-InstalledPrograms.ps1

Use this function as follows:

PS C:\> Get-InstalledPrograms *firefox* | Format-List

DisplayName     : Mozilla Firefox 83.0 (x64 en-US)
UninstallString : "C:\Program Files\Mozilla Firefox\uninstall\helper.exe"
ModifyPath      :