From a01c6969774811ca13b89232ac90de2bf317bc47 Mon Sep 17 00:00:00 2001 From: Vitalii Chulak Date: Mon, 9 Dec 2024 12:14:00 +0200 Subject: [PATCH] RHEL-69597: [CollectSystemInfo] Gather SetupAPI logs Signed-off-by: Vitalii Chulak --- Tools/debug/CollectSystemInfo.ps1 | 23 +++++++++++++++++++++++ Tools/debug/README.md | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Tools/debug/CollectSystemInfo.ps1 b/Tools/debug/CollectSystemInfo.ps1 index 303eb4ee5..90b54531d 100644 --- a/Tools/debug/CollectSystemInfo.ps1 +++ b/Tools/debug/CollectSystemInfo.ps1 @@ -194,6 +194,28 @@ function Export-WindowsMemoryDump { Write-Host 'Windows memory dump collection completed.' } +function Export-SetupAPILogs { + try { + $infPath = "$env:SystemRoot\INF" + $files = Get-ChildItem -Path $infPath -Filter 'setupapi*.log' + + if (Test-Path "$env:SystemRoot\setupapi.log") { + $files += Get-Item "$env:SystemRoot\setupapi.log" + } + + foreach ($file in $files) { + try { + Copy-Item -Path $file.FullName -Destination $logfolderPath -ErrorAction Stop + } catch { + Write-Warning "Failed to copy $($file.Name): $_" + } + } + Write-Host 'SetupAPI logs collection completed.' + } catch { + Write-Warning "Failed to collect SetupAPI logs: $_" + } +} + function Write-InformationToArchive { param ( [string]$FolderPath, @@ -265,6 +287,7 @@ try { Export-InstalledApplications Export-InstalledKBs Export-NetworkConfiguration + Export-SetupAPILogs if ($IncludeSensitiveData) { Write-Output "Dump folder path: $dumpfolderPath" diff --git a/Tools/debug/README.md b/Tools/debug/README.md index 0ff930abb..3f2659ade 100644 --- a/Tools/debug/README.md +++ b/Tools/debug/README.md @@ -2,7 +2,7 @@ ## Overview -This PowerShell script is designed for comprehensive system diagnostics. It gathers a wide range of information, including system configuration, event logs, drivers, registry settings, update logs, services, uptime, processes, installed applications, installed KBs (knowledge base articles), network configuration, and optionally, memory dumps. +This PowerShell script is designed for comprehensive system diagnostics. It gathers a wide range of information, including system configuration, event logs, driver lists, SetupAPI logs, registry settings, update logs, services, uptime, processes, installed applications, installed KBs (knowledge base articles), network configuration, and optionally, memory dumps. The collected data is organized into two subfolders within the time-stamped summary folder, one for log and the other for dump. and then compressed into two ZIP archives correspondingly for easy sharing and analysis. @@ -47,6 +47,7 @@ The collected data is organized into two subfolders within the time-stamped summ - `InstalledApplications.csv`: List of installed applications. - `InstalledKBs.csv`: List of installed Windows updates. - `NetworkInterfaces.txt` and `IPConfiguration.txt`: Network configuration details. +- `setupapi*.log`: Logs related to device and driver installations. - `MEMORY.DMP` and `Minidump` folder: Full or mini memory dumps (if `-IncludeSensitiveData` is used). - `Collecting_Status.txt`: Generated during data collection and deleted after completion. If the script is interrupted, this file indicates incomplete data collection.