Skip to content

Commit 01dd805

Browse files
authored
Merge pull request #35 from fadwen/fix/timeline-rolled-log
fix(logs): read the kind of a timeline from a rolled log file
2 parents 10ab7f3 + 1118621 commit 01dd805

5 files changed

Lines changed: 54 additions & 21 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ release notes.
1111

1212
## [Unreleased]
1313

14-
Nothing yet.
14+
### Fixed
15+
16+
- `Get-IntuneAgentTimeline` reported `Kind` as `Unknown` for a policy or app whose lines all sat in
17+
a rolled log file: the rolled name (`HealthScripts-20260925-101500`) lost only its time part, so it
18+
never matched the log table. Both parts come off now, and such a timeline reads as Remediation or
19+
Win32App like one from the current file.
20+
- The README's Enrollment Status Page block showed the `Log` column before it abbreviated
21+
`IntuneManagementExtension` to `Agent`, and its diagnostic block showed the result as a table
22+
where it has printed as a list with the size in MB since 0.28.0. Both now show what the commands
23+
print.
1524

1625
## [0.31.0] - 2026-10-09
1726

‎Private/ConvertFrom-IslCmTraceLog.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function ConvertFrom-IslCmTraceLog {
1616
and Id are left empty for Get-IntuneAgentLog to fill.
1717
1818
The filters are the ones Get-IntuneAgentLog offers, applied to the raw record before an
19-
object is built for it. Building the object is most of what an entry costs, so a filtered
20-
read of a 22 MB log takes seconds where building every entry takes a minute.
19+
object is built for it. Building the object is most of what an entry costs: on a 15 MB log
20+
of 80,000 entries, one policy by -Id reads in 5 seconds where every entry takes 30.
2121
2222
.PARAMETER Path
2323
The log file to parse.
@@ -91,7 +91,7 @@ function ConvertFrom-IslCmTraceLog {
9191
$ordinalIgnoreCase = [System.StringComparison]::OrdinalIgnoreCase
9292
$ordinal = [System.StringComparison]::Ordinal
9393

94-
# An agent log of 22 MB is 80,000 entries, and every statement here runs once per entry. The
94+
# An agent log of 15 MB is 80,000 entries, and every statement here runs once per entry. The
9595
# attributes come out of one compiled regex in the order the agent writes them, the timestamp
9696
# is read the way ConvertTo-IslCmTraceTime reads it without the call, and the filters run on
9797
# the raw strings before anything is built. Lines are counted only up to an entry that is kept

‎Public/Get-IntuneAgentTimeline.ps1‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function Get-IntuneAgentTimeline {
5656
Message = $_.Message
5757
}
5858
})
59-
$logsSeen = @($steps | ForEach-Object { $_.Log -replace '-\d+$', '' } | Sort-Object -Unique)
59+
# A rolled file is HealthScripts-20260925-101500: both date and time come off, or the name
60+
# never matches the table and a policy whose lines all sit in a rolled file reads as Unknown
61+
$logsSeen = @($steps | ForEach-Object { $_.Log -replace '-\d{8}-\d{6}$', '' } | Sort-Object -Unique)
6062
$kind = 'Unknown'
6163
foreach ($seen in $logsSeen) {
6264
if ($kindByLog.ContainsKey($seen)) { $kind = $kindByLog[$seen]; break }

‎README.md‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,20 @@ shared access, so the live agent is no obstacle, and a copied log folder works w
438438

439439
```powershell
440440
Get-IntuneAgentLog -EventName ScriptEspPhase, EspPhase, EspAppsSelected, EspAppRegistered,
441-
EspAppState, EspPhaseComplete, EspComplete, EspNontrackedCheckin
442-
443-
Time Log Event Detail
444-
---- --- ----- ------
445-
09-28 07:06:00.847 IntuneManagementExtension ScriptEspPhase DeviceSetup
446-
09-28 07:06:12.299 AppWorkload EspPhase DeviceSetup
447-
09-28 07:06:25.611 AppWorkload EspAppsSelected 2
448-
09-28 07:06:31.011 AppWorkload EspAppRegistered DeviceSetup ISL-ESP-DEV-W32-BLOCK1
449-
09-28 07:07:31.199 AppWorkload EspAppState InProgress Completed
450-
09-28 07:08:20.385 AppWorkload EspPhaseComplete device
451-
09-28 07:08:37.882 AppWorkload EspPhase AccountSetup
452-
09-28 07:11:22.504 AppWorkload EspComplete
453-
09-28 07:12:22.658 IntuneManagementExtension EspNontrackedCheckin True
441+
EspAppState, EspPhaseComplete, EspComplete, EspNontrackedCheckin |
442+
Format-Table Time, Log, Event, Detail
443+
444+
Time Log Event Detail
445+
---- --- ----- ------
446+
09-28 07:06:00.847 Agent ScriptEspPhase DeviceSetup
447+
09-28 07:06:12.299 AppWorkload EspPhase DeviceSetup
448+
09-28 07:06:25.611 AppWorkload EspAppsSelected 2
449+
09-28 07:06:31.011 AppWorkload EspAppRegistered DeviceSetup ISL-ESP-DEV-W32-BLOCK1
450+
09-28 07:07:31.199 AppWorkload EspAppState InProgress Completed
451+
09-28 07:08:20.385 AppWorkload EspPhaseComplete device
452+
09-28 07:08:37.882 AppWorkload EspPhase AccountSetup
453+
09-28 07:11:22.504 AppWorkload EspComplete
454+
09-28 07:12:22.658 Agent EspNontrackedCheckin True
454455
```
455456

456457
One Autopilot run (Validation\Findings.md, "The Enrollment Status Page") fixed where scripts sit
@@ -474,9 +475,12 @@ Started Kind Name Duration Runs Outcome
474475
475476
Export-IntuneAgentDiagnostic -Path C:\Temp\intune-diag.zip
476477
477-
Path Files Logs Registry Timeline SizeBytes
478-
---- ----- ---- -------- -------- ---------
479-
C:\Temp\intune-diag.zip 14 6 True True 2318402
478+
Path : C:\Temp\intune-diag.zip
479+
Size : 2.9 MB
480+
Files : 29
481+
Logs : 20
482+
Registry : True
483+
Timeline : True
480484
```
481485

482486
`Get-IntuneAgentTimeline` groups the named log lines by the policy or app they belong to, so one

‎Tests/Unit/Public/Get-IntuneAgentTimeline.Tests.ps1‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ Describe 'Get-IntuneAgentTimeline' -Tag 'Unit', 'Public' {
116116
$platform.Outcome | Should-Be 'ScriptPolicyResult Failed'
117117
$platform.Duration.TotalSeconds | Should-Be 20
118118
}
119+
120+
It 'reads the kind from a rolled log file as it does from the current one' {
121+
# The agent rolls HealthScripts.log over to HealthScripts-<date>-<time>.log; a policy
122+
# whose lines all sit in the rolled file is still a remediation
123+
$rolled = Join-Path $TestDrive 'Rolled'
124+
$hs = @{ Component = 'HealthScripts' }
125+
Write-TestLog $rolled 'HealthScripts-20260925-101500.log' @(
126+
New-CmTraceLine @hs -Time '08:45:14.0000000' -Message ("[HS] Runner: script $($script:Policy) " +
127+
'will try to execute now.')
128+
New-CmTraceLine @hs -Time '08:46:56.0000000' -Message ('[HS] new result = {"PolicyId":"' +
129+
$script:Policy + '","Result":3}')
130+
)
131+
$timeline = @(Get-IntuneAgentTimeline -Path $rolled)
132+
$timeline.Count | Should-Be 1
133+
$timeline[0].Kind | Should-Be 'Remediation'
134+
$timeline[0].Steps[0].Log | Should-Be 'HealthScripts-20260925-101500'
135+
$timeline[0].Outcome | Should-Be 'RemediationReport 3'
136+
}
119137
}
120138

121139
Context 'Filters' {

0 commit comments

Comments
 (0)