I am trying to get the product codes of all the Visual C++ 2008 Installed on my device and wrote the below code but I am stuck. Code Executes but no action takes place. Please Assist.
$log = "C:\VC2008.log"
$regkey = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName)
$RegKey.PSObject.Properties | ForEach-Object {
If($_.Name -like '*DisplayName*')
{
If ($_.value -like 'Microsoft Visual C++ 2008')
{
"$date [INFO]`t $regkey.PSChildname found in Registry !!! " | Out-File $log -append
}
}
}
So you're retrieving your values incorrectly and over-complicating things.
Working solution:
Output:
Test key: