Check if 2 registry keys exists

Hi,
I want to check if 2 registry keys exists and if they don’t I want to execute an install if they do I want to show message already installed and end the install process
I checked with Get-RegistryKey but do not know how to check for 2 keys, same with Get-InstalledApplication this is for Visual_C++_Redistribuable_Miscrosoft_2022_x86x64
when i try to install , i get error that it is already installed.

Thanks for any assistance

Reviewing the syntax for Get-RegistryKey here:

Something like this should work (N.B. This is completely untested)

if ((Get-RegistryKey -key 'keypath' -Name 'Path') -eq 'value') -or (Get-RegistryKey -key 'keypath' -Name 'Path')) -eq 'value') {
    # Registry key (or keys) match
    # Do your action here
} else {
    # No matching registry keys found
    # Perform your warning action here
}
1 Like

Thanks , I tried but It did not work, Probably my bad, but I used an detection of version installed via my Intune console to deploy and that was alot simplier.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.