Skip to content

Commit 09a8bad

Browse files
authored
Merge pull request #220 from microsoft/neils-updates
Neils updates
2 parents f128316 + a0c8039 commit 09a8bad

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# MDM Check-in Monitor
2+
3+
## Overview
4+
Real-time monitoring tool that detects and displays Microsoft Intune MDM check-in events on macOS by streaming unified log entries from the `mdmclient` process.
5+
6+
## Prerequisites
7+
- macOS device enrolled in Microsoft Intune
8+
- Terminal access
9+
- Root/sudo privileges (required for log streaming)
10+
11+
## Usage
12+
1. Navigate to the tool directory:
13+
```bash
14+
cd macOS/Tools/mdmCheckinMonitor
15+
```
16+
17+
2. Make the script executable (if needed):
18+
```bash
19+
chmod +x monitorMdmCheckin.zsh
20+
```
21+
22+
3. Run the monitor with sudo:
23+
```bash
24+
sudo ./monitorMdmCheckin.zsh
25+
```
26+
27+
4. The script will continuously monitor for MDM check-in events. Press `Ctrl+C` to stop monitoring.
28+
29+
## What it monitors
30+
The script watches for MDM client check-in events by filtering the unified log stream for:
31+
- Process: `mdmclient`
32+
- Event type: DeclarativeManagement requests for Device context
33+
- Message pattern: `"Processing server request: DeclarativeManagement for"` containing `"<Device>"`
34+
35+
## Output
36+
When an MDM check-in is detected, the script displays:
37+
- Timestamp of detection
38+
- Full log entry from `mdmclient`
39+
- Separator line for readability
40+
41+
Example output:
42+
```
43+
Monitoring for MDM client check-in events...
44+
Press Ctrl+C to exit
45+
46+
[2025-11-04 14:32:15] MDM Check-in detected:
47+
2025-11-04 14:32:15.123456+0000 0x12345 Info 0x0 mdmclient: Processing server request: DeclarativeManagement for <Device>
48+
-------------------------
49+
```
50+
51+
## Use cases
52+
- Verify MDM check-in timing and frequency
53+
- Troubleshoot MDM communication issues
54+
- Monitor device management activity in real-time
55+
- Correlate MDM events with other system behavior
56+
57+
## Notes
58+
- The script runs continuously until manually stopped with `Ctrl+C`
59+
- This is a monitoring-only tool and takes no actions on the system
60+
- Log streaming may show a brief "Filtering the log data..." header at startup (automatically ignored)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# This is a proof of concept script to detect macOS MDM check-in from the log stream
3+
# neiljohn@microsoft.com
4+
5+
echo "Monitoring for MDM client check-in events..."
6+
echo "Press Ctrl+C to exit"
7+
echo ""
8+
9+
# Stream logs using a predicate that filters on mdmclient,
10+
# checks for the check-in message, and ensures "<Device>" is present.
11+
/usr/bin/log stream --info --predicate 'process=="mdmclient" AND composedMessage CONTAINS "Processing server request: DeclarativeManagement for" AND composedMessage CONTAINS "<Device>"' | while IFS= read -r line; do
12+
# Skip the header line printed by log
13+
if [[ "$line" == Filtering\ the\ log\ data* ]]; then
14+
continue
15+
fi
16+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] MDM Check-in detected:"
17+
echo "$line"
18+
echo "-------------------------"
19+
done

0 commit comments

Comments
 (0)