Intune Custom Detection Script

%3CLINGO-SUB%20id%3D%22lingo-sub-2976839%22%20slang%3D%22en-US%22%3EIntune%20Custom%20Detection%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2976839%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20the%20script%20below%20to%20detect%20if%20the%20config.xml%20file%20is%20deployed.%26nbsp%3B%20This%20script%20runs%20and%20deploys%20the%20file%20and%20I%20find%20that%20in%20the%20IntuneManagementExtension%20log%20the%20'Found%20XML%20File'%20is%20listed%20and%20also%20believe%20I%20have%20found%20the%20app%20code%20with%20'Detected%20App'.%26nbsp%3B%20It%20seems%20the%20exit%20code%20is%20also%20zero%20but%20the%20application%20is%20not%20detected.%26nbsp%3B%20This%20Win32App%20is%20running%20in%20the%20user%20context.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20checked%20the%20admin%20centre%20and%20it%20says%20the%20application%20is%20installed%20but%20this%20is%20not%20what%20the%20company%20portal%20says%2C%20this%20says%20its%20failed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20sure%20what%20I%20am%20missing.%26nbsp%3B%20Any%20thoughts%20as%20to%20why%20the%20Company%20Portal%20does%20not%20reflect%20the%20correct%20status%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23%20All%20files%20created%20in%20the%20month%20of%20November%3CBR%20%2F%3E%24CheckMonth%20%3D%20%2211%22%3CBR%20%2F%3E%24CheckYear%20%3D%20%222021%22%3C%2FP%3E%3CP%3E%24UserProfile%20%3D%20%24env%3AUSERPROFILE%3CBR%20%2F%3Eif%20(Test-Path%20%22%24UserProfile%5CAppdata%5CRoaming%5CSystem%5Cconfig.xml%22)%20%7B%3CBR%20%2F%3E%24FileMonth%20%3D%20(get-item%20%22%24UserProfile%5CAppdata%5CRoaming%5CSystem%5Cdbconfig.xml%22).Lastwritetime.month%3CBR%20%2F%3E%24FileYear%20%3D%20(get-item%20%22%24UserProfile%5CAppdata%5CRoaming%5CSystem%5Cconfig.xml%22).Lastwritetime.Year%3CBR%20%2F%3E%24FileDay%20%3D%20(get-item%20%22%24UserProfile%5CAppdata%5CRoaming%5CSystem%5Cconfig.xml%22).Lastwritetime.Day%3CBR%20%2F%3EIf%20(%24FileMonth%20-ne%20%24CheckMonth)%20%7BExit%7D%3CBR%20%2F%3EIf%20(%24FileYear%20-ne%20%24CheckYear)%20%7BExit%7D%3CBR%20%2F%3EWrite-Host%20%22Found%20XML%20File%22%26nbsp%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

I have the script below to detect if the config.xml file is deployed.  This script runs and deploys the file and I find that in the IntuneManagementExtension log the 'Found XML File' is listed and also believe I have found the app code with 'Detected App'.  It seems the exit code is also zero but the application is not detected.  This Win32App is running in the user context.  

 

I have checked the admin centre and it says the application is installed but this is not what the company portal says, this says its failed.

 

Not sure what I am missing.  Any thoughts as to why the Company Portal does not reflect the correct status?

 

# All files created in the month of November
$CheckMonth = "11"
$CheckYear = "2021"

$UserProfile = $env:USERPROFILE
if (Test-Path "$UserProfile\Appdata\Roaming\System\config.xml") {
$FileMonth = (get-item "$UserProfile\Appdata\Roaming\System\dbconfig.xml").Lastwritetime.month
$FileYear = (get-item "$UserProfile\Appdata\Roaming\System\config.xml").Lastwritetime.Year
$FileDay = (get-item "$UserProfile\Appdata\Roaming\System\config.xml").Lastwritetime.Day
If ($FileMonth -ne $CheckMonth) {Exit}
If ($FileYear -ne $CheckYear) {Exit}
Write-Host "Found XML File" 
}

0 Replies