Reputation: 41
I have Remediation script to detect any installations of an app on our estate. It is known to be installed in one of two locations:
The issue I have is my detection script is not picking up an installation in the first install location, even though it is installed. This is the script I'm using:
Try
{
$LocalAppData = "C:\Users\$env:USERNAME\AppData\"
$AppPath = $LocalAppData +"roaming\*App*\bin\"
$EXEPath = $AppPath +"*App*.exe"
$LocalAppData2 = "C:\Program Files"
$AppPath2 = $LocalAppData2 +"\*App*\bin\"
$EXEPath2 = $AppPath2 +"*App*.exe"
If ($(Test-Path -Path $EXEPath) -eq $True) {
Write-Host "*App* is installed in Roaming Folder"
exit 1
}
elseif
($(Test-Path -Path $EXEPath2) -eq $True) {
Write-Host "*App* is installed in Program Files"
Exit 1
}
else
{
#No remediation required
Write-Host "*App* is not installed"
exit 0
}
}
catch {
$errMsg = $_.Exception.Message
Write-Error $errMsg
# exit 1
}
Running the script in Powershell displays that the app is installed - as expected
Thanks
Upvotes: 0
Views: 3491
Reputation: 558
You must set "Run this script using the logged-on credentials" to Yes in intune App Settings
Upvotes: 0