Photo by Anastasia Zhenina / Unsplash
How to Configure Log File Settings for the Intune Management Extension Service

How to Configure Log File Settings for the Intune Management Extension Service

Published on 04 Apr 2023

Bastien Perez
Bastien Perez

Clap

When using the Microsoft Intune cloud-based service to manage devices and applications, it's important to ensure that the Intune Management Extension service is configured correctly. One important aspect of this configuration is setting up log file settings that enable you to troubleshoot issues that might arise with the service.

In this article, I'll explain why configuring log file settings is important and show you how to configure these settings using PowerShell.

Why Configure Log File Settings for the Intune Management Extension Service?

The Intune Management Extension service is responsible for executing PowerShell scripts and Win32 apps on managed devices. When these scripts and apps fail to run or encounter errors, it's important to have log files that can help you diagnose and troubleshoot the issues. Without proper log file settings, you might miss important details that can help you resolve issues quickly and effectively.

Default Log File Settings for the Intune Management Extension Service

By default, the Intune Management Extension service stores log files in the following directory: %ProgramData%\Microsoft\IntuneManagementExtension\Logs.

The service retains 3 logs files:

  • the file IntuneManagementExtension.log which always contains the latest information
  • two archive files IntuneManagementExtension-<date>.log.  Each file has a maximum size of about 3 MB. When the IntuneManagementExtension.log file reaches its maximum size (about 3MB per file), this file is renamed to IntuneManagementExtension-<date>.log.

Configuring Log File Settings for the Intune Management Extension Service

The following script configure logs settings to increase the log file size and retention for the Intune Management Extension service to enable extended log analysis for troubleshooting and monitoring purposes.

Specifically, you'll need to set:

  • LogMaxSize the maximum log file size in bytes
  • LogMaxHistory  the maximum number of log files to retain, respectively.
LogMaxHistory is only for archive files.

So if you set the value to 5, there will be 6 files kept (the IntuneManagementExtension.log file and 5 archive versions).

Configure with Powershell

Here's an example PowerShell script that sets the LogMaxSize value to 10 MB (which is 10,485,760 bytes) and the LogMaxHistory value to 10, which will keep up to 10 versions of the log file with a maximum size of 10 MB each. The script then restarts the Intune Management Extension service to apply the changes.

Of course, you can deploy this script with Intune.

# Set the maximum log file size in bytes (10MB)
$maxLogSizeInBytes = 10485760

# Set the maximum number of log files to retain
$maxLogFiles = 10

# Check if the logging key exists and create it if it doesn't
if (-not (Test-Path "HKLM:\SOFTWARE\Microsoft\IntuneWindowsAgent\Logging")) {
    $null = New-Item -Path "HKLM:\SOFTWARE\Microsoft\IntuneWindowsAgent\Logging"
}

# Set the registry values for the log file settings
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\IntuneWindowsAgent\Logging" -Name "LogMaxSize" -Value "$maxLogSizeInBytes"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\IntuneWindowsAgent\Logging" -Name "LogMaxHistory" -Value "$maxLogFiles"

# Restart the Intune Management Extension service to apply the changes
Restart-Service -Name "IntuneManagementExtension"

Comments

banner-Bastien Perez
Bastien Perez

Freelance Microsoft 365 - Active Directory - Modern Workplace

France