If you need a list of installed MSI packages and their product codes, you can use WMI to query the information. This may take a couple of seconds:
Get-CimInstance -ClassName Win32_Product | Select-Object -Property Name, @{Name='ProductCode'; Expression={$_.IdentifyingNumber}}