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
	)

	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 {
		 -not $PSBoundParameters.ContainsKey('DisplayName') -or (
			$_.PSObject.Properties.Name -contains 'DisplayName' -and $_.DisplayName -like $DisplayName
		);
	} | Select-Object 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      :