On Windows 10 and better, finding MSI packages and their product codes no longer requires WMI queries. Instead, you can use Get-Package:
Get-Package | Select-Object -Property Name, @{ Name='ProductCode' Expression={ $code = $_.Metadata["ProductCode"] if ([string]::IsNullOrWhiteSpace($code) -eq $false) { $code } else { 'N/A' } } } | Format-List