$approvedApplications = @("Notepad++ (64-bit x64)","brave2typo")
$booapprovedApplications = $false
function Get-InstalledApps {
if (![Environment]::Is64BitProcess) {
$arrRegistryPaths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*')
}
else {
$arrRegistryPaths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKCU:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
}
$arrUninstallRegistrations = @()
foreach ($registryPath in $arrRegistryPaths) {
if (Test-Path $registryPath) {
$arrUninstallRegistrations += Get-ItemProperty $registryPath
}
}
$arrInstalledApps = @()
foreach ($uninstallRegistration in $arrUninstallRegistrations) {
if ($uninstallRegistration.DisplayName -ne $null) {
$arrInstalledApps += $uninstallRegistration.DisplayName
}
}
return $arrInstalledApps
}
$arrInstalledApplications = Get-InstalledApps
foreach ($installedApplication in $arrInstalledApplications) {
foreach ($ApprovedApplication in $approvedApplications) {
if ($installedApplication -eq $ApprovedApplication) {
$booapprovedApplications = $true}
#else {$booapprovedApplications = $False}
}
}
if ($booapprovedApplications) {
$appStatus = @{"Installation status" = "approved app installed"}
}
else {
$appStatus = @{"Installation status" = "Not all approved apps installed"}
}
return $appStatus
Hi
I’m trying to check for multiple approved apps and if they are installed it reports “compliant/approved app installed” if not it reports “not all approved apps installed”
when I use the array with one app it works as expected reporting as “compliant” when i enter more than one app into the array with typo(intentionally)like the example it reports compliant
what am I missing here?
Thanks