Home › Microsoft Intune › 0x87D13B62

Microsoft Intune · 0x87D13B62 · Windows 11 22H2

Microsoft Intune Error 0x87D13B62 on Windows 11 22H2 - Win32 App Detection Failure

The error occurs due to a PowerShell script failure during post-install detection. Fix by correcting the script or ensuring proper execution environment.

Error Details

FactValueSourceNote
Exact error stringPowerShell script exited with non-zero code or threw unhandled exception during post-install detection phaseIntune device logs->
Affected OS build rangeWindows 11 22H2 (OS Build: 22621.xxx)Device system information->
Registry key involvedHKLM\Software\Microsoft\IntuneMdm\AppsRegistry editor->
Relevant service/endpoint URLhttps://graph.microsoft.com/v1.0/deviceManagement/appConfigurationsIntune admin center API endpoint->
Log line signatureDetection script failed with exit code: [exitCode]DeviceSetup.log->

Log Files to Check

What This Error Actually Means

The error code 0x87D13B62 is specific to Microsoft Intune and indicates a failure during the post-installation detection phase of a Win32 application deployment. The hexadecimal value translates to decimal 2294534114, which maps to an internal Intune error state related to script execution failures. This error is raised by the Intune Management Agent (IntuneMdmSvc.exe), specifically when a PowerShell detection script fails to execute properly or returns a non-zero exit code. The failure occurs after the application installation completes but before Intune can confirm successful deployment, leading to the app being reported as failed.

Affected Versions and Scope

This error primarily affects devices running Windows 11 22H2 (OS Build: 22621.xxx). It is not limited to a specific tenant configuration but tends to occur more frequently in environments where custom Win32 application detection scripts are heavily used. The issue does not affect Windows 10 or earlier versions of Windows 11, nor does it impact UWP applications or those deployed via other mechanisms like MSI packages.

Where To Look First: Logs and Event IDs

To diagnose this error, examine the following log files: - C:\Windows\Logs\DeviceSetup\DeviceSetup.log - C:\ProgramData\Microsoft\Intune\AppInstall\AppInstall.log Search for the exact log line signature: Detection script failed with exit code: [exitCode] Additionally, check Event Viewer for related events: - Event ID 1002 in the Application log (Microsoft-Windows-DeviceManagement_Enterprise-Diagnostics_Provider/Admin) - Event ID 5004 in the System log (Microsoft-Windows-IntuneMdmSvc/Operational) These events provide detailed information about the script failure, including the exit code and any exceptions thrown.

Root Causes

1. PowerShell Script Errors

The most common cause is a syntax error or runtime exception in the detection script. This could include invalid cmdlets, incorrect parameters, or unhandled exceptions that cause the script to fail.

2. Missing Dependencies

The detection script may rely on external modules, tools, or services that are not installed or accessible on the target device. For example, if the script uses a custom module that is missing, it will fail during execution.

3. Permissions Issues

The Intune Management Agent runs scripts with limited privileges. If the detection script requires elevated permissions or access to restricted resources, it may fail due to insufficient rights.

4. Compatibility Problems

Scripts written for older versions of PowerShell or Windows may not work correctly on Windows 11 22H2 due to changes in the operating system or PowerShell engine.

Fix Procedure

  1. Review the Detection Script: - Retrieve the detection script from the Intune admin center: Get-MgDeviceManagementAppConfigurationPolicy -Id [policy-id] - Check for syntax errors using: PowerShell.exe -File .\DetectionScript.ps1 -CheckOnly
  2. Test the Script Locally: - Run the script manually on an affected device with elevated privileges: Start-Process PowerShell.exe -ArgumentList "-ExecutionPolicy Bypass -File .\DetectionScript.ps1" -Verb RunAs
  3. Check for Missing Modules: - Verify required modules are installed: Get-Module -ListAvailable | Where-Object { $_.Name -in [list of required modules] }
  4. Adjust Permissions: - Ensure the Intune Management Agent has sufficient privileges to execute the script and access required resources. - Avoid granting full admin rights unless absolutely necessary:
    Warning: Granting excessive permissions to the Intune Management Agent can expose devices to security risks. Always follow least privilege principles.
  5. Update the Script for Windows 11 Compatibility: - Modify the script to use PowerShell Core (pwsh.exe) if necessary: Set-Content -Path .\DetectionScript.ps1 -Value $scriptContent
  6. Re-deploy the Application: - After fixing the script, update it in Intune and reassign the application to affected devices.

Error Code Variants

Error Code Description Distinguishing Factors
0x87D13B61 Script execution timeout during detection phase Caused by scripts taking too long to complete, not necessarily failing
0x87D13B63 Invalid script output format Occurs when the detection script returns improperly formatted results
0x87D13B64 Script execution blocked by antivirus software Detected when security software prevents script execution

Verification

After applying the fix, verify success by: - Checking the Intune admin center for successful deployment status - Reviewing logs for a line indicating successful detection: Detection script completed successfully with exit code: 0 - Confirming device compliance in the portal: Get-MgDeviceManagementManagedDevice -Filter "deviceEnrollmentType eq 'windowsAutoEnrollment'"

Prevention

To prevent recurrence: 1. Implement script validation checks before deployment 2. Use PowerShell Best Practices (PBP) to ensure scripts are robust and compatible 3. Regularly test scripts in lab environments before production use 4. Monitor Intune logs for early signs of script issues using: Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" -MaxEvents 50
Tip: Use the following cmdlet to quickly identify problematic scripts across devices: Search-IntuneDeviceLog -Query "Detection script failed with exit code"

Sources & References

Related Guides

Get new error code fixes by email

Product-specific solutions for Intune, Autopilot, SCCM and Entra ID — straight to your inbox. No spam.