Donnerstag, 12. Februar 2026
Eine schnelle und kleine Lösung, um Logfiles mit PowerShell zu sammeln. Zur Erweiterung / Ideenfindung einfach mal hier eingetragen. KI Form
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# --- GUI Setup ---
$form = New-Object System.Windows.Forms.Form
$form.Text = "Log Collector GUI"
$form.Size = New-Object System.Drawing.Size(800,600)
$form.StartPosition = "CenterScreen"
$label = New-Object System.Windows.Forms.Label
$label.Text = "Wähle Log-Samples zur Erfassung"
$label.AutoSize = $true
$label.Font = New-Object System.Drawing.Font("Arial",10,[System.Drawing.FontStyle]::Bold)
$label.Location = New-Object System.Drawing.Point(20,10)
$form.Controls.Add($label)
# --- Checkboxen ---
$checkboxes = @{}
$logs = @(
"Application Event Log",
"Battery Report",
"Sleepstudy",
"IpConfig All",
"Installed Apps List",
"Network Adapter Details",
"Scheduled Tasks",
"Service Tag + Model Info"
"Windows Update-Protokoll - Get-Hotfix - "
)
$yPos = 40
foreach ($log in $logs) {
$cb = New-Object System.Windows.Forms.CheckBox
$cb.Text = $log
$cb.AutoSize = $true
$cb.Location = New-Object System.Drawing.Point(20,$yPos)
$form.Controls.Add($cb)
$checkboxes[$log] = $cb
$yPos += 30
}
# --- Start Button ---
$btnStart = New-Object System.Windows.Forms.Button
$btnStart.Text = "Start Collection"
$btnStart.Size = New-Object System.Drawing.Size(150,30)
$btnStart.Location = New-Object System.Drawing.Point(20,450)
$form.Controls.Add($btnStart)
# --- Status Label ---
$status = New-Object System.Windows.Forms.Label
$status.Text = "Status: Wartet auf Auswahl..."
$status.AutoSize = $true
$status.Location = New-Object System.Drawing.Point(20,500)
$form.Controls.Add($status)
# --- Collection Logic ---
$btnStart.Add_Click({
$tempDir = Join-Path $env:TEMP ("Logs_" + (Get-Date -Format "yyyyMMdd_HHmmss"))
New-Item -Path $tempDir -ItemType Directory -Force | Out-Null
$status.Text = "Status: Sammle Logs..."
$form.Refresh()
# Application Event Log
# https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wevtutil
if ($checkboxes["Application Event Log"].Checked) {
wevtutil epl Application /q:"*[System[(Level<=5)]]" (Join-Path $tempDir "application_eventlog.evtx")
}
# Battery Report
#powercfg /batteryreport
if ($checkboxes["Battery Report"].Checked) {
powercfg /batteryreport /output (Join-Path $tempDir "Battery_Report.html") /duration 14
}
#Sleepstudy
#https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options
if ($checkboxes["Sleepstudy"].Checked) {
powercfg /sleepstudy /output (Join-Path $tempDir "sleepstudy.html")
}
# IpConfig All
if ($checkboxes["IpConfig All"].Checked) {
ipconfig /all > (Join-Path $tempDir "ipconfig_all.txt")
}
# Installed Apps List
if ($checkboxes["Installed Apps List"].Checked) {
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select DisplayName,DisplayVersion,Publisher,InstallDate |
Sort InstallDate |
Format-Table –AutoSize |
Out-File (Join-Path $tempDir "installed_apps.txt")
}
# Network Adapter Details
if ($checkboxes["Network Adapter Details"].Checked) {
Get-NetAdapter |
Select Name,Status,MacAddress,LinkSpeed |
Format-Table –AutoSize |
Out-File (Join-Path $tempDir "netadapter_details.txt")
}
# Scheduled Tasks
if ($checkboxes["Scheduled Tasks"].Checked) {
Get-ScheduledTask | Where State -ne "Disabled" | Get-ScheduledTaskInfo |
Format-Table –AutoSize |
Out-File (Join-Path $tempDir "taskscheduler.txt")
}
# Service Tag + Model Info
if ($checkboxes["Service Tag + Model Info"].Checked) {
$tag = Get-CimInstance Win32_BIOS | Select-Object -ExpandProperty SerialNumber
$model = Get-CimInstance Win32_ComputerSystem | Select-Object -ExpandProperty Model
"$model`t$tag" | Out-File (Join-Path $tempDir "system_info.txt")
}
# Windows Update-Protokoll - Get-Hotfix - "
if ($checkboxes["Windows Update-Protokoll - Get-Hotfix - "].Checked) {
Get-Hotfix | Out-File (Join-Path $tempDir "Hotfix_info.txt")
}
$status.Text = "Status: Fertig! Logs im Ordner: $tempDir"
explorer $tempDir
})
$form.ShowDialog()
Kategorie: programmierung