Gather MDM Logs

SOTI MobiControl
Windows

The Gather MDM Logs script enables IT administrators to remotely collect essential Mobile Device Management (MDM) logs from Windows devices enrolled in SOTI MobiControl. These logs include agent, installer, updater, and MDM diagnostic reports, all of which are crucial for troubleshooting device management, enrollment issues, or performance problems. By using this script, administrators can easily retrieve logs from devices without manual intervention, streamlining the diagnostic process and ensuring quicker resolutions for device management challenges.

Important:
  • It is recommended to test the script on a local/ test machine for its purpose and effects. 
  • SOTI MobiControl will not be responsible for any damage/loss to the data/setup based on the behavior of the script.

Collect MDM logs for windows devices in a zip file

1 try{
2 if(-not (Test-Path -Path 'C:\Logs\')){
3 $logs = New-Item 'C:\Logs\' -ItemType Directory
4 }
5 if((Test-Path -Path 'C:\ProgramData\SOTI\WinAgent.log' -PathType Leaf)){
6 if(-not (Test-Path -Path 'C:\Logs\AgentLogs\')){
7 $agent = New-Item 'C:\Logs\AgentLogs\' -ItemType Directory
8 }
9 Copy-Item 'C:\ProgramData\SOTI\*' -Destination 'C:\Logs\AgentLogs\'
10 }
11 if((Test-Path -Path 'C:\ProgramData\SOTI\MobiControl\Vpn.log' -PathType Leaf)){
12 if(-not (Test-Path -Path 'C:\Logs\VpnLogs\')){
13 $installer = New-Item 'C:\Logs\VpnLogs\' -ItemType Directory
14 }
15 Copy-Item 'C:\ProgramData\SOTI\MobiControl\*' -Destination 'C:\Logs\VpnLogs\'
16 }
17 $mdmDiagnosticReport = MdmDiagnosticsTool.exe -area DeviceProvisioning -cab C:\Logs\MDMDiagnosticReport\Report.cab
18 if((Test-Path -Path 'C:\Logs.zip' -PathType Leaf)){
19 Remove-Item -Path 'C:\Logs.zip'
20 }
21 Compress-Archive 'C:\Logs\*' -DestinationPath 'C:\Logs.zip'
22 if((Test-Path -Path 'C:\Logs.zip' -PathType Leaf)){
23 Remove-Item -Path 'C:\Logs\' -Recurse
24 Write-Host Successfully Collected Logs at "C:\Logs.zip"
25 }
26 }
27 catch{
28 Write-Host Log Collection Failed : $_.Exception.Message
29 }

Was this helpful?

Need more help?
Ask Community