Skip to content
www.mytechnote.ru
Menu
  • Administration
    • Scripts
  • Equipment
    • Reviews
    • Instructions
  • Other
  • English
    • English
    • Русский
Menu

How to Combine All Windows Logs into One File: A Simple Guide

When diagnosing issues on Windows, you may need to analyze multiple event log files at once. Reviewing each file individually can take a lot of time. In this article, we’ll explain how to combine all Windows logs into one file to make it easier to find the information you need.

Why Is Combining Windows Logs Useful?

Each log file (.evtx) contains information about events on the system. By merging them, you can get a complete picture of system activity and more quickly identify the root cause of any instability or failures.

Steps to Combine Windows Logs into One File

Below is a helpful script that automates the process of merging all .evtx files in a folder into a single log file. This greatly simplifies diagnostics and saves time.

How to Use the Script?

  1. Copy the folder with logs (C:\windows\system32\winevt\Logs).
  2. Download the script from GitHub via the provided link.
  3. Run the script and specify the path to the folder with evtx logs using the -FolderPath parameter to combine all logs into one file.

After the script finishes running, you’ll find a merge.evtx file in the logs folder.

Script Text for Merging Logs

Here’s the script text in case you need to save it for future use:

#Original code here : https://github.com/abhinav-eyesOnglass/evtx/tree/master 
# MergeEventsInside.ps1
#
# - v2 : Fixed Installer bug (setting wrong registry keys in v1)
#      : Add the possibility to run the script manually or just double click on it
#
# - v3 : Fixed a bug in FolderPath management to handle path with special characters such ad '[' & ']'
#        Using -LiteralPath instead of -Path and Out-File instead of Add-Content 
#

param(
    [string]$FolderPath
)

# Check if an argument is provided
# If no argument: Look for evtx files in the current folder, supposing it's been started manually 

if (!$FolderPath)
{
    $FolderPath = Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path
}

write-host $FolderPath -ForegroundColor Cyan

# Check the argument is a folder

if ((Test-Path -LiteralPath $FolderPath -PathType Container)-eq $false) {
    $wshell = New-Object -ComObject Wscript.Shell
    $wshell.Popup("This folder doesn't exist!",0,$FolderPath,0x1)
}
else
{
    $ListOfEvtxFiles = (Get-ChildItem -LiteralPath $FolderPath -File -Filter *.evtx | ? { $_.Name -ne "Merge.evtx" }).FullName
    
    # Check if the folder contains .evtx files
    
    if ($ListOfEvtxFiles.count -eq 0)
    {
        $wshell = New-Object -ComObject Wscript.Shell
        $wshell.Popup("Invalid path: Doesn't contain any evtx files!",0,$FolderPath,0x1)
    }
    else
    {

        # Informing the user

        Write-Host "Merge the event files found in the `"$FolderPath`" folder ..."

        # Generate the XML File for the merge operation

        $Filter = "*"
        $StructuredQueryFilePath = $FolderPath+"\StructuredQuery.xml"
        $StructuredQueryXMLFile = New-Item -Path $StructuredQueryFilePath -ItemType File -Force
        
        $String = "<QueryList>`n"
        $String += "  <Query Id=`"0`" Path=`"file://"+$ListOfEvtxFiles[0]+"`">`n"
        $ListOfEvtxFiles | % {
            $String += "    <Select Path=`"file://$_`">"+$Filter+"</Select>`n"
        }
        $String += "  </Query>`n"
        $String += "</QueryList>`n"

        $string | Out-File -LiteralPath $StructuredQueryXMLFile
  
        # Generate the merge operation

        wevtutil /sq epl $StructuredQueryXMLFile "$FolderPath\Merge.evtx" /ow:true

        Write-Host "All the events are merged into the $FolderPath\Merge.evtx file"

        $wshell = New-Object -ComObject Wscript.Shell
        $wshell.Popup("Done in $FolderPath\Merge.evtx",0,"Merge operation",0x1)

    }
}

Benefits of Using the Script

  • Speeds up diagnostics – no need to go through each file individually.
  • Ease of analysis – all events are collected in one place.

Posted on 25.10.202425.10.2024 by sanglyb

Post navigation

← How to Bypass Vulnerability Checks When Importing Docker Containers in Astra Linux
MikroTik: Why Websites Won’t Load with WireGuard or other VPN connection? MTU Issue Solution →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Подписывайтесь

Youtube
vk
telegram
github
twitter
rss
  • Форум
  • Об авторе
  • Поддержать автора

Популярные записи

Новые записи

  • How to Extend an LVM Partition in Linux
  • SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019
  • Problem Using PassFiltEx on Older CPUs
  • How to remove attachments from old calendar events in Exchange using a script
  • How to download and install Office 2024 LTSC

Архивы

  • 2026 (3)
  • 2025 (5)
  • 2024 (7)
  • 2023 (30)
  • 2022 (4)
  • 2020 (17)
  • 2017 (82)
  • 2016 (5)
© 2015-2026 www.mytechnote.ru
Использование материалов сайта возможно только с разрешения владельца или обязательна индексируемая, прямая, передающая вес ссылка на материал.