For troubleshooting purposes it is helpful to change the log level of the Intune Management Extension. Since this has to be done in an XML config file of the IME and this can affect the function of the IME when inserting a wrong value. I wrote a script which make the change of the log level easy.

How to change the log level
To change the log level of the Ime you have to open the config file. You can find it under the following path: C:\Program Files (x86)\Microsoft Intune Management Extension\Microsoft.Management.Services.IntuneWindowsAgent.exe.config
In this you will find the system.diagnostics setting here there is the attribute switchValue with which you define the log level.

Get the different log level
To write the script I first have to find out what log levels actually exist. Since there is no documentation for this, let alone this is self-explanatory, I have to find a way to get to the values. Where better to find this information than directly in the code of the IME. The Ime is C# compiled code, so I started looking for a C# decompiler and found it with JustDecompile. I downloaded this and installed it on my system.
How does decompiling the IME work now? This is actually really simple. I navigated to the path of the IME (C:\Program Files (x86)\Microsoft Intune Management Extension) and can easily decompile it with a right click:

After that I searched for the function that writes the logs and found the different event types


The script
With this information I wrote a script which changes the log level in the XML and restarts the service. You can find the script in my Git hub repository.
<#
Version: 1.0
Author: Jannik Reinhard (jannikreinhard.com)
Script: Change-ImeLogLevel
Description:
Change the loglevel from the Intune management extension
Release notes:
Version 1.0: Init
#>
$logLevelSelection = Read-Host "Enter the log level [Critical, Error, Warning, Information, Verbose]"
while("Critical", "Error", "Warning", "Information", "Verbose" -notcontains $logLevelSelection )
{
$logLevelSelection = Read-Host "Enter the log level [Critical, Error, Warning, Information, Verbose]"
}
$imeConfFile = "C:\Program Files (x86)\Microsoft Intune Management Extension\Microsoft.Management.Services.IntuneWindowsAgent.exe.config"
$configFile = New-Object System.XML.XMLDocument
$configFile.Load($imeConfFile)
$logLevel = $configFile.configuration.'system.diagnostics'.sources.source
$logLevel.switchValue = "$logLevelSelection"
$configFile.Save($imeConfFile)
Restart-Service -DisplayName "Microsoft Intune Management Extension"
Write-Host "IME Log level changed to $logLevelSelection"
You only have to run the script, select the log level and that’s it

Conclusion
Sometimes it is really a big help to read more from a logfile to understand the IME better or simplify for troubleshooting purposes. I hope I could help you with my blog so you can read more from the IME log.
When you are done with troubleshooting or testing, always reset the IME to the information state and delete the log file as it may contain sensitive information.
Stay healthy, Cheers
Jannik
Update 02.08.2022
You can also download my script from the PowerShell Gallery:
Install-Script -Name Change-ImeLogLevel
[…] this works I have already explained in deep in this blog. Also I wrote a script which helps you to change the log level. You can find this script in my […]
LikeLike
this doesn’t work as now IME service can’t even start. when i tried restart it manually, it said something like “IME service started and then stopped…”
restart machine won’t help. i compare the xml file in Microsoft.Management.Services.IntuneWindowsAgent.exe.config from a working pc to this pc that was ran with your script. both has the same letter and everything tho. so idk what is wrong. any idea?
error from your function:
WARNING: IME Log level changed to information
Restart-Service : Failed to start service ‘Microsoft Intune Management Extension (IntuneManagementExtension)’.
At C:\Program Files\WindowsPowerShell\Scripts\Change-ImeLogLevel.ps1:56 char:5
+ Restart-Service -DisplayName “Microsoft Intune Management Extensi …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Restart-Service]
, ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.RestartServiceCommand
WARNING: IME Service was restarted
LikeLike
Can you send me the Xml file or did you check to reset the log level with the script?
LikeLike
I reset it by running “Change-ImeLoglevel” then put “information”. same error.
here is the Xml:
LikeLike
LikeLike
your comment don’t seem to allow me to copy and paste the xml info. what is your email?
LikeLike