EventTraceLogs

Author: Mark Hallman

description

Event Trace Logs

paths

10 paths
paths use Windows environment syntax

collection commands

# PowerShell Artifact Collection Script
# Target: EventTraceLogs
# Run as Administrator

#Requires -RunAsAdministrator

$ErrorActionPreference = "Continue"
$SourceRoot = "C:"
$DestBase   = "D:\Evidence"
$Summary = @{ Copied = 0; Missed = 0; Errors = 0 }

function Collect-Artifact {
    param(
        [Parameter(Mandatory)][string]$SourceDir,
        [Parameter(Mandatory)][string]$FolderName,
        [string]$FileMask = "*"
    )
    # Expand wildcards in any path segment (e.g. 'Program Files*',
    # 'ScreenConnect Client*'). robocopy itself does not glob the source.
    $sources = @(Get-Item -Path $SourceDir -ErrorAction SilentlyContinue |
        Where-Object { $_.PSIsContainer })
    if ($sources.Count -eq 0) {
        $Summary.Missed++
        return
    }
    $FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
    $null = New-Item -ItemType Directory -Force -Path $FullDest -ErrorAction SilentlyContinue
    foreach ($src in $sources) {
        robocopy $src.FullName "$FullDest" "$FileMask" /E /COPY:DAT /R:0 /W:0 /NP /NFL /NDL /NJH /NJS 2>$null | Out-Null
        if ($LASTEXITCODE -le 7) { $Summary.Copied++ } else { $Summary.Errors++ }
    }
}

# 1. WDI Trace Logs 1
Collect-Artifact -SourceDir "C:\Windows\System32\WDI\LogFiles" -FileMask "*.etl*" -FolderName "WDI_Trace_Logs_1"

# 2. WDI Trace Logs 1
Collect-Artifact -SourceDir "C:\Windows.old\Windows\System32\WDI\LogFiles" -FileMask "*.etl*" -FolderName "WDI_Trace_Logs_1"

# 3. WDI Trace Logs 2
Collect-Artifact -SourceDir "C:\Windows\System32\WDI\{*" -FolderName "WDI_Trace_Logs_2"

# 4. WDI Trace Logs 2
Collect-Artifact -SourceDir "C:\Windows.old\Windows\System32\WDI\{*" -FolderName "WDI_Trace_Logs_2"

# 5. WMI Trace Logs
Collect-Artifact -SourceDir "C:\Windows\System32\LogFiles\WMI" -FolderName "WMI_Trace_Logs"

# 6. WMI Trace Logs
Collect-Artifact -SourceDir "C:\Windows.old\Windows\System32\LogFiles\WMI" -FolderName "WMI_Trace_Logs"

# 7. SleepStudy Trace Logs
Collect-Artifact -SourceDir "C:\Windows\System32\SleepStudy" -FolderName "SleepStudy_Trace_Logs"

# 8. SleepStudy Trace Logs
Collect-Artifact -SourceDir "C:\Windows.old\Windows\System32\SleepStudy" -FolderName "SleepStudy_Trace_Logs"

# 9. Energy-NTKL Trace Logs
Collect-Artifact -SourceDir "C:\ProgramData\Microsoft\Windows\PowerEfficiency Diagnostics" -FileMask "energy-ntkl.etl" -FolderName "Energy_NTKL_Trace_Logs"

# 10. Delivery Optimization Trace Logs
Collect-Artifact -SourceDir "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\DeliveryOptimization\Logs" -FileMask "*.etl*" -FolderName "Delivery_Optimization_Trace_Logs"

Write-Host ("Collection complete. Copied: {0}  Missed: {1}  Errors: {2}" -f $Summary.Copied, $Summary.Missed, $Summary.Errors) -ForegroundColor Green

Save as .ps1 and run as Administrator. Use: powershell -ExecutionPolicy Bypass -File script.ps1

references

included in collections