Skip to content

Instantly share code, notes, and snippets.

@williamjacksn
Created May 12, 2011 18:50
Show Gist options
  • Save williamjacksn/969188 to your computer and use it in GitHub Desktop.
Save williamjacksn/969188 to your computer and use it in GitHub Desktop.
Application Detection and Compliance with PowerShell
$app_name = "*flash player*"
$app_ver = "10.3.183.5"
$reg_uninstall_keys = "hklm:software\wow6432node\microsoft\windows\currentversion\uninstall", "hklm:\software\microsoft\windows\currentversion\uninstall"
[array]$compliant = (
$reg_uninstall_keys | foreach-object {
if (test-path $_) {
get-childitem $_ | get-itemproperty | select-object displayname, displayversion
}
}
) | where-object {$_.displayname -like $app_name -and $_.displayversion -eq $application_version}
if ($compliant -ne $null) {
write-host "Compliant"
} else {
write-host "NotCompliant"
}
$app_name = "*flash player*"
$reg_uninstall_keys = "hklm:software\wow6432node\microsoft\windows\currentversion\uninstall", "hklm:\software\microsoft\windows\currentversion\uninstall"
[array]$detected = (
$reg_uninstall_keys | foreach-object {
if (test-path $_) {
get-childitem $_ | get-itemproperty | select-object displayname
}
}
) | where-object {$_.displayname -like $app_name}
if ($detected -ne $null) {
write-host "Detected"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment