$product = foreach ($product in (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*)) {
$props = @{
'DisplayName' = $product.DisplayName;
'InstallLocation' = $product.InstallLocation;
'InstallSource' = $product.InstallSource;
'InstallDate' = $product.InstallDate;
'Version' = $product.DisplayVersion;
'Uninstall_Command' = $product.UninstallString;
}
New-Object -TypeName PSObject -Property $props
}
$process | Select-Object DisplayName,InstallLocation,InstallSource,Version,Uninstall_Command | ft # | ConvertTo-Json
You are creating $product
and using $process
which is not a valid variable here.
2 Likes