Apr 08 2024 04:24 PM
Hi,
I am attempting to create an Intune Win32 App package that will apply a custom theme to our computers.
custom.theme and lockscreen.jpg get copied to C:\Windows\Resources\Themes.
A folder named DesktopBackground is copied to C:\Windows\Resources\Themes and contains 35 jpg files.
The detection script for this should be extremely simple but when I install this package, it is always seen as not-compliant by Intune. The detection script checks the two files at C:\Windows\Resources\Themes and gets a count of jpg files in C:\Windows\Resources\Themes\DesktopBackground (must be 35 or more to be compliant). I cannot use manual rules because of the 25-rule restriction.
Here is my detection script:
# Initialize variables
$compliant = 0
$backgroundPath = "C:\Windows\Resources\Themes\DesktopBackground"
$file1 = "C:\Windows\Resources\Themes\custom.theme"
$file2 = "C:\Windows\Resources\Themes\LockScreen.jpg"
$logFile = "C:\Windows\Temp\complianceLog.txt"
# Test compliance
# custom.theme
if(-not(Test-Path -Path $file1)) {
# custom.theme does not exist
$compliant = 1
Add-Content -Path $logFile -Value "custom.theme does not exist"
}
# LockScreen.jpg
if(-not(Test-Path -Path $file2)) {
# LockScreen.jpg does not exist
$compliant = 1
Add-Content -Path $logFile -Value "LockScreen.jpg does not exist"
}
$fileCount = (Get-Childitem -Path $backgroundPath).Count
if($fileCount -lt 35) {
# The number of desktop background slides is incorrect
$compliant = 1
Add-Content -Path $logFile -Value "The number of desktop background slides is incorrect"
}
if($compliant -eq 0) {
Add-Content -Path $logFile -Value "Installation is compliant"
Exit 0
} else {
Add-Content -Path $logFile -Value "Installation is not compliant"
Exit 1
}
This script always detects the installation as not-compliant, but all the expected files and folders are found in their place as expected. The result should be compliant.
Any ideas what is tripping up this detection?
Thank you!
Rob
Apr 09 2024 02:19 AM
SolutionApr 09 2024 07:15 AM
Apr 09 2024 07:32 AM
Is this what you are suggesting?
if($compliant -eq 0) {
Add-Content -Path $logFile -Value "Installation is compliant"
Write-Output "Installation is compliant"
Exit 0
} else {
Add-Content -Path $logFile -Value "Installation is not compliant"
Write-Output "Installation is not compliant"
Exit 1
}
Apr 09 2024 07:35 AM
Apr 09 2024 07:40 AM
Apr 09 2024 07:55 AM
Apr 09 2024 09:17 AM
Apr 09 2024 02:19 AM
Solution