uj könyvtär Scripts
This commit is contained in:
47
Scripts/powershell/Drucker_Überwachung_0.1.ps1
Normal file
47
Scripts/powershell/Drucker_Überwachung_0.1.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
$events = Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" -MaxEvents 500 |
|
||||
Where-Object { $_.Id -eq 307 }
|
||||
|
||||
$logList = @()
|
||||
|
||||
foreach ($event in $events) {
|
||||
$message = $event.Message
|
||||
$user = ""
|
||||
$document = ""
|
||||
$printer = ""
|
||||
$pages = ""
|
||||
|
||||
# Felhasználó (pl. L.Vogt auf APS-NB072)
|
||||
if ($message -match "im Besitz von (.+?) wurde auf") {
|
||||
$user = $matches[1].Trim()
|
||||
}
|
||||
|
||||
# Nyomtató neve (pl. Jasenitz)
|
||||
if ($message -match "wurde auf (.+?) über Port") {
|
||||
$printer = $matches[1].Trim()
|
||||
}
|
||||
|
||||
# Oldalszám (pl. Gedruckte Seiten: 1)
|
||||
if ($message -match "Gedruckte Seiten:\s+(\d+)") {
|
||||
$pages = $matches[1]
|
||||
}
|
||||
|
||||
# Dokumentum sorszám (pl. Dokument 62) – jobb híján
|
||||
if ($message -match "^Dokument\s+(\d+)") {
|
||||
$document = "Dokument " + $matches[1]
|
||||
}
|
||||
|
||||
$logList += [PSCustomObject]@{
|
||||
Datum = $event.TimeCreated
|
||||
Benutzer = $user
|
||||
Dokument = $document
|
||||
Drucker = $printer
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
|
||||
# Exportálás CSV-be
|
||||
$exportPfad = "$env:USERPROFILE\Desktop\drucklog_export.csv"
|
||||
$logList | Export-Csv -Path $exportPfad -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Write-Host "Exportálás kész: $exportPfad"
|
||||
|
||||
Reference in New Issue
Block a user