Skip to content

Instantly share code, notes, and snippets.

@RobinBeismann
Created August 4, 2022 09:37
Show Gist options
  • Save RobinBeismann/e1fa42f31c19e856b3e479e94c48ef93 to your computer and use it in GitHub Desktop.
Save RobinBeismann/e1fa42f31c19e856b3e479e94c48ef93 to your computer and use it in GitHub Desktop.
[array]$AppName = "Microsoft Visual C++ 2015-2019", "Microsoft Visual C++ 2015-2022"
[version]$RequiredVersion = "14.27.29112.0"
[string]$Architecture = "x64"
[array]$Hives = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\",
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$Hives | ForEach-Object {
Get-ChildItem -Path $_ | ForEach-Object {
$Properties = $_ | Get-ItemProperty
if(
$Properties.DisplayName -and
$Properties.DisplayName.Contains("$("($Architecture)")") -and
(
$AppName | Where-Object {
$Properties.DisplayName.StartsWith($_)
}
)
){
$CurrentVersion = [version]$Properties.DisplayVersion
if($CurrentVersion -ge $RequiredVersion){
"installed"
}
}
}
}
@harris1m
Copy link

Works a treat! Thank you.

@RobinBeismann
Copy link
Author

RobinBeismann commented Sep 26, 2023

Works a treat! Thank you.

Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment