uj könyvtär Scripts
This commit is contained in:
67
Scripts/bash/ovh_dnsupdate.sh
Normal file
67
Scripts/bash/ovh_dnsupdate.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
# ovh-dynhost-update.sh - POSIX sh verzió
|
||||
|
||||
# ---------- Konfiguráció ----------
|
||||
DH_USER="meszely.eu-matrix"
|
||||
DH_PASS="virgI6774#Panda"
|
||||
HOSTNAME="home.meszely.eu"
|
||||
LOGFILE="/var/log/ovh-dynhost-update.log"
|
||||
# ---------- VÉGE konfiguráció ----------
|
||||
|
||||
log() {
|
||||
echo "$(date -Iseconds) - $*" >> "${LOGFILE}" 2>/dev/null || echo "$*"
|
||||
}
|
||||
|
||||
get_public_ip() {
|
||||
curl -fsS https://api.ipify.org || echo ""
|
||||
}
|
||||
|
||||
get_dns_ip() {
|
||||
dig +short A "${HOSTNAME}" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -n1 || echo ""
|
||||
}
|
||||
|
||||
update_ovh() {
|
||||
ip="$1"
|
||||
curl -fsS --max-time 30 --user "${DH_USER}:${DH_PASS}" \
|
||||
"https://www.ovh.com/nic/update?system=dyndns&hostname=${HOSTNAME}&myip=${ip}" || echo ""
|
||||
}
|
||||
|
||||
main() {
|
||||
log "Script indítva — host: ${HOSTNAME}"
|
||||
|
||||
public_ip="$(get_public_ip)"
|
||||
if [ -z "$public_ip" ]; then
|
||||
log "Hiba: nem sikerült lekérni a publikus IP-t."
|
||||
exit 1
|
||||
fi
|
||||
log "Publikus IP: $public_ip"
|
||||
|
||||
dns_ip="$(get_dns_ip)"
|
||||
if [ -z "$dns_ip" ]; then
|
||||
log "Nincs A rekord jelenleg vagy nem elérhető (dns_ip üres)."
|
||||
else
|
||||
log "DNS-en található A rekord: $dns_ip"
|
||||
fi
|
||||
|
||||
if [ "$public_ip" = "$dns_ip" ]; then
|
||||
log "IP nem változott (nochg). Nem frissítünk."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log "IP eltér — frissítés OVH felé..."
|
||||
response="$(update_ovh "$public_ip")"
|
||||
log "OVH válasz: $response"
|
||||
|
||||
case "$response" in
|
||||
good*|nochg*)
|
||||
log "Sikeres frissítés: $response"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log "Frissítés sikertelen: $response"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
11
Scripts/hp aruba switch/firmware_update.md
Normal file
11
Scripts/hp aruba switch/firmware_update.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# COMx port Speed 115200
|
||||
#
|
||||
show images
|
||||
|
||||
mount usb
|
||||
|
||||
copy usb:/AOS-CX_6100-6000_10_16_1006.swi primary
|
||||
|
||||
boot system primary
|
||||
|
||||
erase all zeroize
|
||||
33
Scripts/powershell/Benutzer_Data.ps1
Normal file
33
Scripts/powershell/Benutzer_Data.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
Import-Module ActiveDirectory -ErrorAction Stop
|
||||
|
||||
$out = 'C:\Apps\all_ad_users.csv'
|
||||
|
||||
Get-ADUser -Filter * -Properties mail,telephoneNumber,mobile,fax,physicalDeliveryOfficeName,department,title,Enabled |
|
||||
Select-Object @{
|
||||
Name='Name';Expression={$_.Name}
|
||||
}, @{
|
||||
Name='SamAccountName';Expression={$_.SamAccountName}
|
||||
}, @{
|
||||
Name='Mail';Expression={$_.mail}
|
||||
}, @{
|
||||
Name='Telephone';Expression={$_.telephoneNumber}
|
||||
}, @{
|
||||
Name='Mobile';Expression={$_.mobile}
|
||||
}, @{
|
||||
Name='Fax_business';Expression={$_.fax}
|
||||
}, @{
|
||||
Name='Office';Expression={$_.physicalDeliveryOfficeName}
|
||||
}, @{
|
||||
Name='Department';Expression={$_.department}
|
||||
}, @{
|
||||
Name='Title';Expression={$_.title}
|
||||
}, @{
|
||||
Name='Enabled';Expression={$_.Enabled}
|
||||
} |
|
||||
Tee-Object -Variable Results |
|
||||
Export-Csv -Path $out -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# konzolra formázott megjelenítés (szükség szerint szűrj)
|
||||
$Results | Format-Table Name,SamAccountName,Mail,Telephone,Mobile,Fax_business,Office,Department,Title,Enabled -AutoSize
|
||||
|
||||
Write-Host "Kimenet: $out ($($Results.Count) felhasználó)"
|
||||
58
Scripts/powershell/Benutzer_Data_from_group_email.ps1
Normal file
58
Scripts/powershell/Benutzer_Data_from_group_email.ps1
Normal file
@@ -0,0 +1,58 @@
|
||||
Import-Module ActiveDirectory -ErrorAction Stop
|
||||
|
||||
# --- Állítsd be a csoport e-mail címét vagy nevét ---
|
||||
$groupEmail = "abteilungsleitungen-jenfeld@aps-hh.de"
|
||||
$out = "C:\Tools\group_members.csv"
|
||||
|
||||
# --- Csoport objektum lekérése az e-mail cím alapján ---
|
||||
$group = Get-ADGroup -Filter "mail -eq '$groupEmail'" -Properties mail
|
||||
|
||||
if (-not $group) {
|
||||
Write-Host "Nem található csoport ezzel az e-mail címmel: $groupEmail" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "Csoport megtalálva: $($group.Name) ($($group.DistinguishedName))"
|
||||
|
||||
# --- Csoporttagok lekérése ---
|
||||
$members = Get-ADGroupMember -Identity $group.DistinguishedName -Recursive | Where-Object { $_.ObjectClass -eq 'user' }
|
||||
|
||||
if (-not $members) {
|
||||
Write-Host "Nincsenek felhasználók a csoportban vagy nincs jogosultság a lekérdezéshez." -ForegroundColor Yellow
|
||||
exit
|
||||
}
|
||||
|
||||
# --- AD-felhasználói adatok lekérése ---
|
||||
$Results = $members | ForEach-Object {
|
||||
Get-ADUser -Identity $_.SamAccountName -Properties mail,telephoneNumber,mobile,fax,physicalDeliveryOfficeName,department,title,Enabled |
|
||||
Select-Object @{
|
||||
Name='Name';Expression={$_.Name}
|
||||
}, @{
|
||||
Name='SamAccountName';Expression={$_.SamAccountName}
|
||||
}, @{
|
||||
Name='Mail';Expression={$_.mail}
|
||||
}, @{
|
||||
Name='Telephone';Expression={$_.telephoneNumber}
|
||||
}, @{
|
||||
Name='Mobile';Expression={$_.mobile}
|
||||
}, @{
|
||||
Name='Fax_business';Expression={$_.fax}
|
||||
}, @{
|
||||
Name='Office';Expression={$_.physicalDeliveryOfficeName}
|
||||
}, @{
|
||||
Name='Department';Expression={$_.department}
|
||||
}, @{
|
||||
Name='Title';Expression={$_.title}
|
||||
}, @{
|
||||
Name='Enabled';Expression={$_.Enabled}
|
||||
}
|
||||
}
|
||||
|
||||
# --- Export CSV ---
|
||||
$Results | Export-Csv -Path $out -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# --- Konzolos megjelenítés ---
|
||||
$Results | Format-Table Name,SamAccountName,Mail,Telephone,Mobile,Fax_business,Office,Department,Title,Enabled -AutoSize
|
||||
|
||||
Write-Host "`nCsoport: $($group.Name)"
|
||||
Write-Host "Kimenet: $out ($($Results.Count) felhasználó)" -ForegroundColor Green
|
||||
39
Scripts/powershell/Benutzer_Data_from_txt.ps1
Normal file
39
Scripts/powershell/Benutzer_Data_from_txt.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
Import-Module ActiveDirectory -ErrorAction Stop
|
||||
|
||||
$in = 'C:\Tools\users.txt'
|
||||
$out = 'C:\Tools\selected_users.csv'
|
||||
|
||||
# Felhasználónevek beolvasása a txt-ből, üres sorokat kihagyva, szóközöket levágva
|
||||
$userList = Get-Content -Path $in | Where-Object { $_.Trim() -ne "" } | ForEach-Object { $_.Trim() }
|
||||
|
||||
# AD-lekérdezés és szűrés a txt alapján
|
||||
Get-ADUser -Filter * -Properties mail,telephoneNumber,mobile,fax,physicalDeliveryOfficeName,department,title,Enabled |
|
||||
Where-Object { $userList -contains $_.Name } |
|
||||
Select-Object @{
|
||||
Name='Name';Expression={$_.Name}
|
||||
}, @{
|
||||
Name='SamAccountName';Expression={$_.SamAccountName}
|
||||
}, @{
|
||||
Name='Mail';Expression={$_.mail}
|
||||
}, @{
|
||||
Name='Telephone';Expression={$_.telephoneNumber}
|
||||
}, @{
|
||||
Name='Mobile';Expression={$_.mobile}
|
||||
}, @{
|
||||
Name='Fax_business';Expression={$_.fax}
|
||||
}, @{
|
||||
Name='Office';Expression={$_.physicalDeliveryOfficeName}
|
||||
}, @{
|
||||
Name='Department';Expression={$_.department}
|
||||
}, @{
|
||||
Name='Title';Expression={$_.title}
|
||||
}, @{
|
||||
Name='Enabled';Expression={$_.Enabled}
|
||||
} |
|
||||
Tee-Object -Variable Results |
|
||||
Export-Csv -Path $out -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# konzolra formázott megjelenítés
|
||||
$Results | Format-Table Name,SamAccountName,Mail,Telephone,Mobile,Fax_business,Office,Department,Title,Enabled -AutoSize
|
||||
|
||||
Write-Host "Kimenet: $out ($($Results.Count) felhasználó)"
|
||||
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"
|
||||
|
||||
54
Scripts/powershell/Drucker_Überwachung_0.2.ps1
Normal file
54
Scripts/powershell/Drucker_Überwachung_0.2.ps1
Normal file
@@ -0,0 +1,54 @@
|
||||
$events = Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" -MaxEvents 500 |
|
||||
Where-Object { $_.Id -eq 307 }
|
||||
|
||||
$logList = @()
|
||||
|
||||
foreach ($event in $events) {
|
||||
$message = $event.Message
|
||||
$user = ""
|
||||
$computer = ""
|
||||
$document = ""
|
||||
$printer = ""
|
||||
$pages = ""
|
||||
|
||||
# Felhasználó és gép különválasztása
|
||||
if ($message -match "im Besitz von (.+?) wurde auf") {
|
||||
$fullUser = $matches[1].Trim()
|
||||
if ($fullUser -match "^(.+?) auf (.+)$") {
|
||||
$user = $matches[1].Trim()
|
||||
$computer = $matches[2].Trim()
|
||||
} else {
|
||||
$user = $fullUser
|
||||
}
|
||||
}
|
||||
|
||||
# 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]
|
||||
}
|
||||
|
||||
# Dokument sorszám (pl. Dokument 62)
|
||||
if ($message -match "^Dokument\s+(\d+)") {
|
||||
$document = "Dokument " + $matches[1]
|
||||
}
|
||||
|
||||
$logList += [PSCustomObject]@{
|
||||
Datum = $event.TimeCreated
|
||||
Benutzer = $user
|
||||
Computer = $computer
|
||||
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"
|
||||
75
Scripts/powershell/Drucker_Überwachung_0.3.ps1
Normal file
75
Scripts/powershell/Drucker_Überwachung_0.3.ps1
Normal file
@@ -0,0 +1,75 @@
|
||||
# Printer Log Report 0.3
|
||||
#
|
||||
# Get-WinEvent on Englische Windows : Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational"
|
||||
# Get-WinEvent on Deutsche Windows : Get-WinEvent -LogName "Microsoft-Windows-PrintService/Betriebsbereit"
|
||||
|
||||
$events = Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" -MaxEvents 500 |
|
||||
Where-Object { $_.Id -eq 307 }
|
||||
|
||||
$logList = @()
|
||||
|
||||
foreach ($event in $events) {
|
||||
$message = $event.Message
|
||||
$user = ""
|
||||
$computer = ""
|
||||
$document = ""
|
||||
$printer = ""
|
||||
$pages = 0
|
||||
|
||||
# Felhasználó és gép különválasztása
|
||||
if ($message -match "im Besitz von (.+?) wurde auf") {
|
||||
$fullUser = $matches[1].Trim()
|
||||
if ($fullUser -match "^(.+?) auf (.+)$") {
|
||||
$user = $matches[1].Trim()
|
||||
$computer = $matches[2].Trim()
|
||||
} else {
|
||||
$user = $fullUser
|
||||
}
|
||||
}
|
||||
|
||||
# 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 = [int]$matches[1]
|
||||
}
|
||||
|
||||
# Dokument sorszám (pl. Dokument 62)
|
||||
if ($message -match "^Dokument\s+(\d+)") {
|
||||
$document = "Dokument " + $matches[1]
|
||||
}
|
||||
|
||||
$logList += [PSCustomObject]@{
|
||||
Datum = $event.TimeCreated
|
||||
Benutzer = $user
|
||||
Computer = $computer
|
||||
Dokument = $document
|
||||
Drucker = $printer
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
|
||||
# Export részletes lista
|
||||
$exportPfad = "$env:USERPROFILE\Desktop\drucklog_export.csv"
|
||||
$logList | Export-Csv -Path $exportPfad -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# ✅ Összesítés felhasználónként
|
||||
$summary = $logList | Group-Object -Property Benutzer | ForEach-Object {
|
||||
$userGroup = $_.Group
|
||||
[PSCustomObject]@{
|
||||
Benutzer = $_.Name
|
||||
Anzahl_Dokumente = $userGroup.Count
|
||||
Gesamt_Seiten = ($userGroup | Measure-Object -Property Seiten -Sum).Sum
|
||||
}
|
||||
}
|
||||
|
||||
# Export összesítés
|
||||
$summaryPfad = "$env:USERPROFILE\Desktop\drucklog_summary.csv"
|
||||
$summary | Export-Csv -Path $summaryPfad -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Write-Host "Exportálás kész:"
|
||||
Write-Host "- Részletes lista: $exportPfad"
|
||||
Write-Host "- Felhasználónkénti összesítés: $summaryPfad"
|
||||
152
Scripts/powershell/Drucker_Überwachung_0.4.ps1
Normal file
152
Scripts/powershell/Drucker_Überwachung_0.4.ps1
Normal file
@@ -0,0 +1,152 @@
|
||||
# Printer Log Report 0.3
|
||||
#
|
||||
# Get-WinEvent on Englische Windows : Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational"
|
||||
# Get-WinEvent on Deutsche Windows : Get-WinEvent -LogName "Microsoft-Windows-PrintService/Betriebsbereit"
|
||||
|
||||
|
||||
$events = Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" -MaxEvents 2000 |
|
||||
Where-Object { $_.Id -eq 307 }
|
||||
|
||||
$logList = @()
|
||||
|
||||
foreach ($event in $events) {
|
||||
$message = $event.Message
|
||||
$user = ""
|
||||
$computer = ""
|
||||
$document = ""
|
||||
$printer = ""
|
||||
$pages = 0
|
||||
|
||||
if ($message -match "im Besitz von (.+?) wurde auf") {
|
||||
$fullUser = $matches[1].Trim()
|
||||
if ($fullUser -match "^(.+?) auf (.+)$") {
|
||||
$user = $matches[1].Trim()
|
||||
$computer = $matches[2].Trim()
|
||||
} else {
|
||||
$user = $fullUser
|
||||
}
|
||||
}
|
||||
|
||||
if ($message -match "wurde auf (.+?) über Port") {
|
||||
$printer = $matches[1].Trim()
|
||||
}
|
||||
|
||||
if ($message -match "Gedruckte Seiten:\s+(\d+)") {
|
||||
$pages = [int]$matches[1]
|
||||
}
|
||||
|
||||
if ($message -match "^Dokument\s+(\d+)") {
|
||||
$document = "Dokument " + $matches[1]
|
||||
}
|
||||
|
||||
$logList += [PSCustomObject]@{
|
||||
Datum = $event.TimeCreated
|
||||
Tag = $event.TimeCreated.Date.ToString("yyyy-MM-dd")
|
||||
Woche = Get-Date $event.TimeCreated -UFormat "%Y-W%V"
|
||||
Benutzer = $user
|
||||
Computer = $computer
|
||||
Dokument = $document
|
||||
Drucker = $printer
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
|
||||
# 🔹 Export részletes lista
|
||||
$exportPfad = "$env:USERPROFILE\Desktop\drucklog_export.csv"
|
||||
$logList | Export-Csv -Path $exportPfad -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# 🔸 Összesítés felhasználónként (teljes)
|
||||
$summary = $logList | Group-Object -Property Benutzer | ForEach-Object {
|
||||
$userGroup = $_.Group
|
||||
[PSCustomObject]@{
|
||||
Benutzer = $_.Name
|
||||
Anzahl_Dokumente = $userGroup.Count
|
||||
Gesamt_Seiten = ($userGroup | Measure-Object -Property Seiten -Sum).Sum
|
||||
}
|
||||
}
|
||||
$summary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_summary.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# 🔸 Napi összesítés felhasználónként
|
||||
$dailySummary = $logList | Group-Object -Property Tag, Benutzer | ForEach-Object {
|
||||
$day = $_.Group[0].Tag
|
||||
$user = $_.Group[0].Benutzer
|
||||
$pages = ($_.Group | Measure-Object -Property Seiten -Sum).Sum
|
||||
$docs = $_.Count
|
||||
|
||||
[PSCustomObject]@{
|
||||
Datum = $day
|
||||
Benutzer = $user
|
||||
Dokumente = $docs
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
$dailySummary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_daily.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# 🔸 Heti összesítés felhasználónként (ISO hét formátum: pl. 2025-W30)
|
||||
$weeklySummary = $logList | Group-Object -Property Woche, Benutzer | ForEach-Object {
|
||||
$week = $_.Group[0].Woche
|
||||
$user = $_.Group[0].Benutzer
|
||||
$pages = ($_.Group | Measure-Object -Property Seiten -Sum).Sum
|
||||
$docs = $_.Count
|
||||
|
||||
[PSCustomObject]@{
|
||||
Woche = $week
|
||||
Benutzer = $user
|
||||
Dokumente = $docs
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
$weeklySummary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_weekly.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Write-Host "Exportálás kész:"
|
||||
Write-Host "- Részletes lista: drucklog_export.csv"
|
||||
Write-Host "- Összesítés: drucklog_summary.csv"
|
||||
Write-Host "- Napi összesítés: drucklog_daily.csv"
|
||||
Write-Host "- Heti összesítés: drucklog_weekly.csv"
|
||||
|
||||
# 🔸 Nyomtatónkénti összesítés
|
||||
$printerSummary = $logList | Group-Object -Property Drucker | ForEach-Object {
|
||||
$printer = $_.Name
|
||||
$pages = ($_.Group | Measure-Object -Property Seiten -Sum).Sum
|
||||
$docs = $_.Count
|
||||
|
||||
[PSCustomObject]@{
|
||||
Drucker = $printer
|
||||
Dokumente = $docs
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
|
||||
$printerSummary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_by_printer.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# 🔸 Napi összesítés nyomtatónként
|
||||
$dailyPrinterSummary = $logList | Group-Object -Property Tag, Drucker | ForEach-Object {
|
||||
$day = $_.Group[0].Tag
|
||||
$printer = $_.Group[0].Drucker
|
||||
$pages = ($_.Group | Measure-Object -Property Seiten -Sum).Sum
|
||||
$docs = $_.Count
|
||||
|
||||
[PSCustomObject]@{
|
||||
Datum = $day
|
||||
Drucker = $printer
|
||||
Dokumente = $docs
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
$dailyPrinterSummary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_daily_by_printer.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
# 🔸 Heti összesítés nyomtatónként
|
||||
$weeklyPrinterSummary = $logList | Group-Object -Property Woche, Drucker | ForEach-Object {
|
||||
$week = $_.Group[0].Woche
|
||||
$printer = $_.Group[0].Drucker
|
||||
$pages = ($_.Group | Measure-Object -Property Seiten -Sum).Sum
|
||||
$docs = $_.Count
|
||||
|
||||
[PSCustomObject]@{
|
||||
Woche = $week
|
||||
Drucker = $printer
|
||||
Dokumente = $docs
|
||||
Seiten = $pages
|
||||
}
|
||||
}
|
||||
$weeklyPrinterSummary | Export-Csv -Path "$env:USERPROFILE\Desktop\drucklog_weekly_by_printer.csv" -NoTypeInformation -Encoding UTF8
|
||||
98
Scripts/powershell/Drucker_Überwachung_mit_SqlLite_0.1.ps1
Normal file
98
Scripts/powershell/Drucker_Überwachung_mit_SqlLite_0.1.ps1
Normal file
@@ -0,0 +1,98 @@
|
||||
# Drucklog_Export.ps1
|
||||
# Nyomtatási napló beolvasása Event Log-ból, feldolgozása és mentése SQLite adatbázisba duplikációk nélkül
|
||||
# Fontos modul SQLite feldolgozäshoz
|
||||
# Install-Module -Name SQLite -Scope CurrentUser
|
||||
# Import-Module SQLite
|
||||
|
||||
# --- Beállítások ---
|
||||
$logName = "Microsoft-Windows-PrintService/Operational"
|
||||
$dbPath = "$env:USERPROFILE\Desktop\drucklog_APS-PRINT01.db"
|
||||
# $dbPath = "$env:USERPROFILE\Desktop\drucklog_APS-PRINT02.db"
|
||||
|
||||
# --- SQLite kapcsolat ---
|
||||
# Add-Type -Path "C:\Tools\SQLite\System.Data.SQLite.dll"
|
||||
$connectionString = "Data Source=$dbPath;Version=3;"
|
||||
$connection = New-Object System.Data.SQLite.SQLiteConnection($connectionString)
|
||||
$connection.Open()
|
||||
|
||||
# --- Tábla létrehozása, ha nem létezik ---
|
||||
$createTableCmd = $connection.CreateCommand()
|
||||
$createTableCmd.CommandText = @"
|
||||
CREATE TABLE IF NOT EXISTS drucklog (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
event_id INTEGER UNIQUE,
|
||||
datum TEXT,
|
||||
tag TEXT,
|
||||
woche TEXT,
|
||||
benutzer TEXT,
|
||||
computer TEXT,
|
||||
dokument TEXT,
|
||||
drucker TEXT,
|
||||
seiten INTEGER
|
||||
);
|
||||
"@
|
||||
$createTableCmd.ExecuteNonQuery()
|
||||
|
||||
# --- Események lekérdezése ---
|
||||
$events = Get-WinEvent -LogName $logName -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq 307 }
|
||||
|
||||
# --- Adatok feldolgozása ---
|
||||
$logList = foreach ($event in $events) {
|
||||
$msg = $event.Message
|
||||
|
||||
if ($msg -match "im Besitz von (.+?) auf (.+?) wurde auf (.+?) über Port") {
|
||||
$benutzer = $matches[1]
|
||||
$computer = $matches[2]
|
||||
$drucker = $matches[3]
|
||||
}
|
||||
else {
|
||||
continue
|
||||
}
|
||||
|
||||
$dokument = if ($msg -match "Dokument (.+?), Dokument drucken") { $matches[1] } else { "Unbekannt" }
|
||||
$seiten = if ($msg -match "Gedruckte Seiten: (\d+)") { [int]$matches[1] } else { 0 }
|
||||
|
||||
$calendar = [System.Globalization.CultureInfo]::CurrentCulture.Calendar
|
||||
$weekRule = [System.Globalization.CalendarWeekRule]::FirstFourDayWeek
|
||||
$firstDay = [System.DayOfWeek]::Monday
|
||||
$woche = $calendar.GetWeekOfYear($event.TimeCreated, $weekRule, $firstDay)
|
||||
|
||||
[PSCustomObject]@{
|
||||
Id = $event.RecordId
|
||||
Datum = $event.TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
Tag = $event.TimeCreated.ToString("yyyy-MM-dd")
|
||||
Woche = $woche
|
||||
Benutzer = $benutzer
|
||||
Computer = $computer
|
||||
Dokument = $dokument
|
||||
Drucker = $drucker
|
||||
Seiten = $seiten
|
||||
}
|
||||
}
|
||||
|
||||
# --- Adatok mentése adatbázisba, duplikáció nélkül ---
|
||||
foreach ($row in $logList) {
|
||||
$checkCmd = $connection.CreateCommand()
|
||||
$checkCmd.CommandText = "SELECT COUNT(*) FROM drucklog WHERE event_id = @id"
|
||||
$checkCmd.Parameters.AddWithValue("@id", $row.Id)
|
||||
$exists = $checkCmd.ExecuteScalar()
|
||||
|
||||
if ($exists -eq 0) {
|
||||
$insertCmd = $connection.CreateCommand()
|
||||
$insertCmd.CommandText = "INSERT INTO drucklog (event_id, datum, tag, woche, benutzer, computer, dokument, drucker, seiten)
|
||||
VALUES (@id, @datum, @tag, @woche, @benutzer, @computer, @dokument, @drucker, @seiten)"
|
||||
$insertCmd.Parameters.AddWithValue("@id", $row.Id)
|
||||
$insertCmd.Parameters.AddWithValue("@datum", $row.Datum)
|
||||
$insertCmd.Parameters.AddWithValue("@tag", $row.Tag)
|
||||
$insertCmd.Parameters.AddWithValue("@woche", $row.Woche)
|
||||
$insertCmd.Parameters.AddWithValue("@benutzer", $row.Benutzer)
|
||||
$insertCmd.Parameters.AddWithValue("@computer", $row.Computer)
|
||||
$insertCmd.Parameters.AddWithValue("@dokument", $row.Dokument)
|
||||
$insertCmd.Parameters.AddWithValue("@drucker", $row.Drucker)
|
||||
$insertCmd.Parameters.AddWithValue("@seiten", $row.Seiten)
|
||||
$insertCmd.ExecuteNonQuery()
|
||||
}
|
||||
}
|
||||
|
||||
$connection.Close()
|
||||
Write-Host "Sikeresen frissítve: $($logList.Count) esemény feldolgozva."
|
||||
101
Scripts/powershell/Drucker_Überwachung_mit_SqlLite_0.2.ps1
Normal file
101
Scripts/powershell/Drucker_Überwachung_mit_SqlLite_0.2.ps1
Normal file
@@ -0,0 +1,101 @@
|
||||
# Drucklog_Export.ps1
|
||||
# Nyomtatási napló beolvasása Event Log-ból, feldolgozása és mentése SQLite adatbázisba duplikációk nélkül
|
||||
# Fontos modul SQLite feldolgozäshoz
|
||||
# Install-Module -Name SQLite -Scope CurrentUser
|
||||
# Import-Module SQLite
|
||||
|
||||
# --- Beállítások ---
|
||||
$logName = "Microsoft-Windows-PrintService/Operational"
|
||||
$dbPath = "$env:USERPROFILE\Desktop\drucklog_APS-PRINT01.db"
|
||||
# $dbPath = "$env:USERPROFILE\Desktop\drucklog_APS-PRINT02.db"
|
||||
|
||||
# --- SQLite kapcsolat ---
|
||||
# Add-Type -Path "C:\Tools\SQLite\System.Data.SQLite.dll"
|
||||
$connectionString = "Data Source=$dbPath;Version=3;"
|
||||
$connection = New-Object System.Data.SQLite.SQLiteConnection($connectionString)
|
||||
$connection.Open()
|
||||
|
||||
# --- Tábla létrehozása, ha nem létezik ---
|
||||
$createTableCmd = $connection.CreateCommand()
|
||||
$createTableCmd.CommandText = @"
|
||||
CREATE TABLE IF NOT EXISTS drucklog (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
event_id INTEGER UNIQUE,
|
||||
datum TEXT,
|
||||
tag TEXT,
|
||||
woche TEXT,
|
||||
benutzer TEXT,
|
||||
computer TEXT,
|
||||
dokument TEXT,
|
||||
drucker TEXT,
|
||||
seiten INTEGER
|
||||
);
|
||||
"@
|
||||
$createTableCmd.ExecuteNonQuery()
|
||||
|
||||
# --- Események lekérdezése ---
|
||||
$events = Get-WinEvent -LogName $logName -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq 307 }
|
||||
|
||||
# --- Adatok feldolgozása ---
|
||||
$logList = foreach ($event in $events) {
|
||||
$msg = $event.Message
|
||||
|
||||
if ($msg -match "im Besitz von (.+?) auf (.+?) wurde auf (.+?) über Port") {
|
||||
$benutzer = $matches[1]
|
||||
$computer = $matches[2]
|
||||
$drucker = $matches[3]
|
||||
}
|
||||
else {
|
||||
continue
|
||||
}
|
||||
|
||||
$dokument = if ($msg -match "Dokument (.+?), Dokument drucken") { $matches[1] } else { "Unbekannt" }
|
||||
$seiten = if ($msg -match "Gedruckte Seiten: (\d+)") { [int]$matches[1] } else { 0 }
|
||||
|
||||
$calendar = [System.Globalization.CultureInfo]::CurrentCulture.Calendar
|
||||
$weekRule = [System.Globalization.CalendarWeekRule]::FirstFourDayWeek
|
||||
$firstDay = [System.DayOfWeek]::Monday
|
||||
$woche = $calendar.GetWeekOfYear($event.TimeCreated, $weekRule, $firstDay)
|
||||
|
||||
[PSCustomObject]@{
|
||||
Id = $event.RecordId
|
||||
Datum = $event.TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
Tag = $event.TimeCreated.ToString("yyyy-MM-dd")
|
||||
Woche = $woche
|
||||
Benutzer = $benutzer
|
||||
Computer = $computer
|
||||
Dokument = $dokument
|
||||
Drucker = $drucker
|
||||
Seiten = $seiten
|
||||
}
|
||||
}
|
||||
|
||||
# --- Adatok mentése adatbázisba, duplikáció nélkül ---
|
||||
$ujBejegyzesek = 0
|
||||
foreach ($row in $logList) {
|
||||
$checkCmd = $connection.CreateCommand()
|
||||
$checkCmd.CommandText = "SELECT COUNT(*) FROM drucklog WHERE event_id = @id"
|
||||
$checkCmd.Parameters.AddWithValue("@id", $row.Id)
|
||||
$exists = $checkCmd.ExecuteScalar()
|
||||
|
||||
if ($exists -eq 0) {
|
||||
$insertCmd = $connection.CreateCommand()
|
||||
$insertCmd.CommandText = "INSERT INTO drucklog (event_id, datum, tag, woche, benutzer, computer, dokument, drucker, seiten)
|
||||
VALUES (@id, @datum, @tag, @woche, @benutzer, @computer, @dokument, @drucker, @seiten)"
|
||||
$insertCmd.Parameters.AddWithValue("@id", $row.Id)
|
||||
$insertCmd.Parameters.AddWithValue("@datum", $row.Datum)
|
||||
$insertCmd.Parameters.AddWithValue("@tag", $row.Tag)
|
||||
$insertCmd.Parameters.AddWithValue("@woche", $row.Woche)
|
||||
$insertCmd.Parameters.AddWithValue("@benutzer", $row.Benutzer)
|
||||
$insertCmd.Parameters.AddWithValue("@computer", $row.Computer)
|
||||
$insertCmd.Parameters.AddWithValue("@dokument", $row.Dokument)
|
||||
$insertCmd.Parameters.AddWithValue("@drucker", $row.Drucker)
|
||||
$insertCmd.Parameters.AddWithValue("@seiten", $row.Seiten)
|
||||
$insertCmd.ExecuteNonQuery()
|
||||
$ujBejegyzesek++
|
||||
}
|
||||
}
|
||||
|
||||
$connection.Close()
|
||||
Write-Host "Sikeresen frissítve: $($logList.Count) esemény feldolgozva."
|
||||
Write-Host "Új bejegyzések az adatbázisban: $ujBejegyzesek"
|
||||
81
Scripts/powershell/Drucklog_MySQL_0.1-from-Dev.ps1
Normal file
81
Scripts/powershell/Drucklog_MySQL_0.1-from-Dev.ps1
Normal file
@@ -0,0 +1,81 @@
|
||||
# Drucklog_MySQL.ps1
|
||||
# Install-Module MySQLCmdlets
|
||||
# Nyomtatási napló export MySQL adatbázisba
|
||||
# Aufgabeplannung: Taglich um 8.00 Uhr
|
||||
# Name: Drucklog_MySQL_0.1.ps1
|
||||
# powershell.exe -ExecutionPolicy Bypass -File "-ExecutionPolicy Bypass -File "C:\Tools\drucklog_export_0.1.ps1"
|
||||
|
||||
# Beállítások
|
||||
$logName = "Microsoft-Windows-PrintService/Operational"
|
||||
$mysqlHost = "10.101.0.82"
|
||||
$mysqlUser = "druckloguser"
|
||||
$mysqlPassword = "Test123#"
|
||||
$mysqlDatabase = "drucklog"
|
||||
$quelleServer = $env:COMPUTERNAME # vagy: "Szerver01"
|
||||
|
||||
# MySQL .NET csomag betöltése (előzetesen szükséges: MySql.Data.dll)
|
||||
# Add-Type -Path "C:\Tools\MySql.Data.dll"
|
||||
# Add-Type -Path "C:\Program Files (x86)\MySQL\MySQL Connector NET 9.4\MySql.Data.dll"
|
||||
[Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector NET 9.4\MySql.Data.dll") | Out-Null
|
||||
|
||||
# Kapcsolódás
|
||||
$connectionString = "server=$mysqlHost;user id=$mysqlUser;password=$mysqlPassword;database=$mysqlDatabase;SslMode=none"
|
||||
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection($connectionString)
|
||||
$connection.Open()
|
||||
|
||||
# Lekérés a logból
|
||||
$events = Get-WinEvent -LogName $logName -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq 307 }
|
||||
|
||||
# Kulturális beállítás a heti számításhoz
|
||||
$calendar = [System.Globalization.CultureInfo]::CurrentCulture.Calendar
|
||||
$weekRule = [System.Globalization.CalendarWeekRule]::FirstFourDayWeek
|
||||
$firstDay = [System.DayOfWeek]::Monday
|
||||
|
||||
$ujBejegyzes = 0
|
||||
|
||||
foreach ($event in $events) {
|
||||
$msg = $event.Message
|
||||
|
||||
if ($msg -match "im Besitz von (.+?) auf (.+?) wurde auf (.+?) über Port") {
|
||||
$benutzer = $matches[1]
|
||||
$computer = $matches[2]
|
||||
$drucker = $matches[3]
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
$dokument = if ($msg -match "Dokument (.+?), Dokument drucken") { $matches[1] } else { "Unbekannt" }
|
||||
$seiten = if ($msg -match "Gedruckte Seiten: (\d+)") { [int]$matches[1] } else { 0 }
|
||||
$woche = $calendar.GetWeekOfYear($event.TimeCreated, $weekRule, $firstDay)
|
||||
$datum = $event.TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
$tag = $event.TimeCreated.ToString("yyyy-MM-dd")
|
||||
$id = $event.RecordId
|
||||
|
||||
# Duplikáció ellenőrzés
|
||||
$checkCmd = $connection.CreateCommand()
|
||||
$checkCmd.CommandText = "SELECT COUNT(*) FROM drucklog WHERE event_id = @id AND quelle_server = @qs"
|
||||
$checkCmd.Parameters.AddWithValue("@id", $id)
|
||||
$checkCmd.Parameters.AddWithValue("@qs", $quelleServer)
|
||||
$exists = $checkCmd.ExecuteScalar()
|
||||
|
||||
if ($exists -eq 0) {
|
||||
$insertCmd = $connection.CreateCommand()
|
||||
$insertCmd.CommandText = "INSERT INTO drucklog (event_id, datum, tag, woche, benutzer, computer, dokument, drucker, seiten, quelle_server)
|
||||
VALUES (@id, @datum, @tag, @woche, @benutzer, @computer, @dokument, @drucker, @seiten, @qs)"
|
||||
$insertCmd.Parameters.AddWithValue("@id", $id)
|
||||
$insertCmd.Parameters.AddWithValue("@datum", $datum)
|
||||
$insertCmd.Parameters.AddWithValue("@tag", $tag)
|
||||
$insertCmd.Parameters.AddWithValue("@woche", $woche)
|
||||
$insertCmd.Parameters.AddWithValue("@benutzer", $benutzer)
|
||||
$insertCmd.Parameters.AddWithValue("@computer", $computer)
|
||||
$insertCmd.Parameters.AddWithValue("@dokument", $dokument)
|
||||
$insertCmd.Parameters.AddWithValue("@drucker", $drucker)
|
||||
$insertCmd.Parameters.AddWithValue("@seiten", $seiten)
|
||||
$insertCmd.Parameters.AddWithValue("@qs", $quelleServer)
|
||||
$insertCmd.ExecuteNonQuery()
|
||||
$ujBejegyzes++
|
||||
}
|
||||
}
|
||||
|
||||
$connection.Close()
|
||||
Write-Host "Feldolgozott események: $($events.Count) | Új bejegyzés: $ujBejegyzes"
|
||||
78
Scripts/powershell/Drucklog_MySQL_0.1.ps1
Normal file
78
Scripts/powershell/Drucklog_MySQL_0.1.ps1
Normal file
@@ -0,0 +1,78 @@
|
||||
# Drucklog_MySQL.ps1
|
||||
# Install-Module MySQLCmdlets
|
||||
# Nyomtatási napló export MySQL adatbázisba
|
||||
|
||||
# Beállítások
|
||||
$logName = "Microsoft-Windows-PrintService/Operational"
|
||||
$mysqlHost = "10.101.0.82"
|
||||
$mysqlUser = "druckloguser"
|
||||
$mysqlPassword = "Test123#"
|
||||
$mysqlDatabase = "drucklog"
|
||||
$quelleServer = $env:COMPUTERNAME # vagy: "Szerver01"
|
||||
|
||||
# MySQL .NET csomag betöltése (előzetesen szükséges: MySql.Data.dll)
|
||||
# Add-Type -Path "C:\Tools\MySql.Data.dll"
|
||||
# Add-Type -Path "C:\Program Files (x86)\MySQL\MySQL Connector NET 9.4\MySql.Data.dll"
|
||||
[Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector NET 9.4\MySql.Data.dll") | Out-Null
|
||||
|
||||
# Kapcsolódás
|
||||
$connectionString = "server=$mysqlHost;user id=$mysqlUser;password=$mysqlPassword;database=$mysqlDatabase;SslMode=none"
|
||||
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection($connectionString)
|
||||
$connection.Open()
|
||||
|
||||
# Lekérés a logból
|
||||
$events = Get-WinEvent -LogName $logName -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq 307 }
|
||||
|
||||
# Kulturális beállítás a heti számításhoz
|
||||
$calendar = [System.Globalization.CultureInfo]::CurrentCulture.Calendar
|
||||
$weekRule = [System.Globalization.CalendarWeekRule]::FirstFourDayWeek
|
||||
$firstDay = [System.DayOfWeek]::Monday
|
||||
|
||||
$ujBejegyzes = 0
|
||||
|
||||
foreach ($event in $events) {
|
||||
$msg = $event.Message
|
||||
|
||||
if ($msg -match "im Besitz von (.+?) auf (.+?) wurde auf (.+?) über Port") {
|
||||
$benutzer = $matches[1]
|
||||
$computer = $matches[2]
|
||||
$drucker = $matches[3]
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
$dokument = if ($msg -match "Dokument (.+?), Dokument drucken") { $matches[1] } else { "Unbekannt" }
|
||||
$seiten = if ($msg -match "Gedruckte Seiten: (\d+)") { [int]$matches[1] } else { 0 }
|
||||
$woche = $calendar.GetWeekOfYear($event.TimeCreated, $weekRule, $firstDay)
|
||||
$datum = $event.TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
$tag = $event.TimeCreated.ToString("yyyy-MM-dd")
|
||||
$id = $event.RecordId
|
||||
|
||||
# Duplikáció ellenőrzés
|
||||
$checkCmd = $connection.CreateCommand()
|
||||
$checkCmd.CommandText = "SELECT COUNT(*) FROM drucklog WHERE event_id = @id AND quelle_server = @qs"
|
||||
$checkCmd.Parameters.AddWithValue("@id", $id)
|
||||
$checkCmd.Parameters.AddWithValue("@qs", $quelleServer)
|
||||
$exists = $checkCmd.ExecuteScalar()
|
||||
|
||||
if ($exists -eq 0) {
|
||||
$insertCmd = $connection.CreateCommand()
|
||||
$insertCmd.CommandText = "INSERT INTO drucklog (event_id, datum, tag, woche, benutzer, computer, dokument, drucker, seiten, quelle_server)
|
||||
VALUES (@id, @datum, @tag, @woche, @benutzer, @computer, @dokument, @drucker, @seiten, @qs)"
|
||||
$insertCmd.Parameters.AddWithValue("@id", $id)
|
||||
$insertCmd.Parameters.AddWithValue("@datum", $datum)
|
||||
$insertCmd.Parameters.AddWithValue("@tag", $tag)
|
||||
$insertCmd.Parameters.AddWithValue("@woche", $woche)
|
||||
$insertCmd.Parameters.AddWithValue("@benutzer", $benutzer)
|
||||
$insertCmd.Parameters.AddWithValue("@computer", $computer)
|
||||
$insertCmd.Parameters.AddWithValue("@dokument", $dokument)
|
||||
$insertCmd.Parameters.AddWithValue("@drucker", $drucker)
|
||||
$insertCmd.Parameters.AddWithValue("@seiten", $seiten)
|
||||
$insertCmd.Parameters.AddWithValue("@qs", $quelleServer)
|
||||
$insertCmd.ExecuteNonQuery()
|
||||
$ujBejegyzes++
|
||||
}
|
||||
}
|
||||
|
||||
$connection.Close()
|
||||
Write-Host "Feldolgozott események: $($events.Count) | Új bejegyzés: $ujBejegyzes"
|
||||
2
Scripts/powershell/Exchange_Kalender.ps1
Normal file
2
Scripts/powershell/Exchange_Kalender.ps1
Normal file
@@ -0,0 +1,2 @@
|
||||
# Kalender Megosztäs
|
||||
Get-MailboxFolderPermission l.hintz:\Kalender
|
||||
8
Scripts/powershell/Exchange_User_Access.ps1
Normal file
8
Scripts/powershell/Exchange_User_Access.ps1
Normal file
@@ -0,0 +1,8 @@
|
||||
$User = "i.meszely@aps-hh.de"
|
||||
|
||||
# Full Access
|
||||
Get-Mailbox | Get-MailboxPermission | Where-Object { $_.User -like $User -and $_.AccessRights -contains "FullAccess" } | Select-Object Identity, User, AccessRights
|
||||
# Send As
|
||||
Get-Mailbox | Get-ADPermission | Where-Object { $_.User -like $User -and $_.ExtendedRights -like "Send As" } | Select-Object Identity, User, ExtendedRights
|
||||
# Mitglied
|
||||
Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember $_.Identity -ResultSize Unlimited) -contains $User } | Select-Object Name, PrimarySmtpAddress
|
||||
6
Scripts/powershell/Freie_Platz_Hard_Drive.ps1
Normal file
6
Scripts/powershell/Freie_Platz_Hard_Drive.ps1
Normal file
@@ -0,0 +1,6 @@
|
||||
Get-WmiObject -Class Win32_LogicalDisk | ? {$_. DriveType -eq 3} | select DeviceID, {$_.Size /1GB}, {$_.FreeSpace /1GB}
|
||||
|
||||
# z.B. ha csak a C meghajtó érdekel
|
||||
#DeviceID $_.Size /1GB $_.FreeSpace /1GB
|
||||
#-------- ------------ -----------------
|
||||
#C: 99,3974571228027 0,667621612548828
|
||||
33
Scripts/powershell/IMAP PDF attachment downloader.ps1
Normal file
33
Scripts/powershell/IMAP PDF attachment downloader.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
# IMAP PDF attachment downloader (requires MailKit DLL)
|
||||
|
||||
# Először töltsd le a MailKit DLL-t: https://www.nuget.org/packages/MailKit
|
||||
# Példa letöltés: https://github.com/jstedfast/MailKit/releases/latest
|
||||
|
||||
Add-Type -Path "C:\Apps\MailKit\MailKit.dll"
|
||||
Add-Type -Path "C:\Apps\MailKit\MimeKit.dll"
|
||||
|
||||
$imapServer = "your.exchange.server"
|
||||
$imapPort = 993
|
||||
$username = "your-username"
|
||||
$password = "your-password"
|
||||
|
||||
$client = New-Object MailKit.Net.Imap.ImapClient
|
||||
$client.Connect($imapServer, $imapPort, $true)
|
||||
$client.Authenticate($username, $password)
|
||||
$inbox = $client.Inbox
|
||||
$inbox.Open([MailKit.FolderAccess]::ReadOnly)
|
||||
|
||||
foreach ($msg in $inbox.Fetch(0, $inbox.Count - 1, [MailKit.MessageSummaryItems]::Full | [MailKit.MessageSummaryItems]::UniqueId)) {
|
||||
$email = $inbox.GetMessage($msg.UniqueId)
|
||||
foreach ($attachment in $email.Attachments) {
|
||||
if ($attachment.ContentType.MediaType -eq "application" -and $attachment.ContentType.MediaSubtype -eq "pdf") {
|
||||
$filePath = "C:\Downloads\" + $attachment.FileName
|
||||
$stream = [System.IO.File]::Create($filePath)
|
||||
$attachment.Content.DecodeTo($stream)
|
||||
$stream.Close()
|
||||
Write-Host "Downloaded: $filePath"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$client.Disconnect($true)
|
||||
32
Scripts/powershell/Oof_DROP_List.ps1
Normal file
32
Scripts/powershell/Oof_DROP_List.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
# This script retrieves message tracking logs for emails that were dropped by the transport service on the current day.
|
||||
|
||||
# --- Configuration ---
|
||||
# Define the path for the output CSV file.
|
||||
$OutputPath = "C:\Tools\oof_DROP.csv" # You can change this path
|
||||
|
||||
# --- Script ---
|
||||
|
||||
# Set the start and end times for the query to span the entire current day.
|
||||
$startOfDay = (Get-Date).Date
|
||||
$endOfDay = $startOfDay.AddDays(1).AddSeconds(-1)
|
||||
|
||||
Write-Host "Querying message tracking logs for dropped 'Automatic Reply' messages between $startOfDay and $endOfDay..."
|
||||
|
||||
# Query for dropped messages with "Automatische Antwort" in the subject, excluding the postmaster sender.
|
||||
$droppedMessages = Get-TransportService | Get-MessageTrackingLog -wa 0 -EventId "DROP" -MessageSubject "Automatische Antwort" -Start $startOfDay -End $endOfDay | Where-Object { $_.Sender -ne 'postmaster@aps.local' }
|
||||
|
||||
if ($droppedMessages) {
|
||||
# Select the desired properties for both console output and CSV export.
|
||||
$outputData = $droppedMessages | Select-Object Timestamp, EventId, Source, Sender, @{Name='Recipients';Expression={$_.Recipients -join ';'}}, RecipientStatus, MessageSubject, InternalMessageId
|
||||
|
||||
# Display the results in the console.
|
||||
Write-Host "Dropped 'Automatic Reply' messages found:"
|
||||
$outputData | Format-Table
|
||||
|
||||
# Export the results to a CSV file, overwriting if it exists.
|
||||
Write-Host "Exporting results to $OutputPath..."
|
||||
$outputData | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8 -Force
|
||||
Write-Host "Export complete."
|
||||
} else {
|
||||
Write-Host "No dropped 'Automatic Reply' messages found for the current day."
|
||||
}
|
||||
42
Scripts/powershell/Oof_Enabled.ps1
Normal file
42
Scripts/powershell/Oof_Enabled.ps1
Normal file
@@ -0,0 +1,42 @@
|
||||
# Connect to Exchange Online (requires ExchangeOnlineManagement module)
|
||||
# Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber
|
||||
# Connect-ExchangeOnline -ShowProgress $true
|
||||
|
||||
# --- Script ---
|
||||
|
||||
# Get all user mailboxes
|
||||
Write-Host "Retrieving all user mailboxes..."
|
||||
$mailboxes = Get-Mailbox -ResultSize Unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'}
|
||||
|
||||
# Create a container for the OOF enabled users
|
||||
$oofEnabledUsers = @()
|
||||
|
||||
Write-Host "Checking Out of Office status for each mailbox..."
|
||||
foreach ($mailbox in $mailboxes) {
|
||||
try {
|
||||
$oofSettings = Get-MailboxAutoReplyConfiguration -Identity $mailbox.UserPrincipalName
|
||||
|
||||
if ($oofSettings.AutoReplyState -ne "Disabled") {
|
||||
$oofEnabledUsers += [PSCustomObject]@{
|
||||
UserPrincipalName = $mailbox.UserPrincipalName
|
||||
AutoReplyState = $oofSettings.AutoReplyState
|
||||
StartTime = $oofSettings.StartTime
|
||||
EndTime = $oofSettings.EndTime
|
||||
InternalMessage = $oofSettings.InternalMessage
|
||||
ExternalMessage = $oofSettings.ExternalMessage
|
||||
}
|
||||
Write-Host " OOO enabled for $($mailbox.UserPrincipalName)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Could not retrieve OOF settings for $($mailbox.UserPrincipalName). Error: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
# Display the OOF configurations for all users where it's enabled
|
||||
Write-Host "`n--- Summary of Users with Enabled Out of Office ---"
|
||||
if ($oofEnabledUsers.Count -gt 0) {
|
||||
$oofEnabledUsers | Format-Table
|
||||
} else {
|
||||
Write-Host "No users found with Out of Office enabled."
|
||||
}
|
||||
2
Scripts/powershell/Powershell_Ver.ps1
Normal file
2
Scripts/powershell/Powershell_Ver.ps1
Normal file
@@ -0,0 +1,2 @@
|
||||
# Powershell Versio
|
||||
$PSVersionTable
|
||||
16
Scripts/powershell/RDP események exportálása CSV-be.ps1
Normal file
16
Scripts/powershell/RDP események exportálása CSV-be.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
# RDP események exportálása CSV-be
|
||||
Get-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" `
|
||||
| Where-Object { $_.Id -in 21,22,23,24,25,39,40,41 } `
|
||||
| Select-Object TimeCreated, Id, LevelDisplayName, Message `
|
||||
| Export-Csv "C:\Logs\RDP_LocalSessionManager.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Get-WinEvent -LogName "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" `
|
||||
| Select-Object TimeCreated, Id, LevelDisplayName, Message `
|
||||
| Export-Csv "C:\Logs\RDP_RemoteConnectionManager.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Get-WinEvent -LogName "System" | Where-Object { $_.Id -eq 56 -and $_.ProviderName -eq "TermDD" } `
|
||||
| Select-Object TimeCreated, Id, LevelDisplayName, Message `
|
||||
| Export-Csv "C:\Logs\RDP_TermDD.csv" -NoTypeInformation -Encoding UTF8
|
||||
|
||||
|
||||
|
||||
23
Scripts/powershell/SMTP Tester 02.ps1
Normal file
23
Scripts/powershell/SMTP Tester 02.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
$SMTPServer = "smtp.mail.me.com" # Az SMTP szerver címe
|
||||
$SMTPPort = 587 # SMTP port (általában 587 a TLS-hez)
|
||||
$Username = "imeszely@icloud.com" # SMTP felhasználónév
|
||||
$Password = "pandAmacI6774#" # SMTP jelszó
|
||||
|
||||
# SMTP kapcsolat létrehozása
|
||||
$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
|
||||
$SMTPClient.EnableSsl = $true # TLS engedélyezése
|
||||
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
|
||||
|
||||
# Teszt e-mail küldése
|
||||
$MailMessage = New-Object System.Net.Mail.MailMessage
|
||||
$MailMessage.From = "imeszely@icloud.com"
|
||||
$MailMessage.To.Add("istvan@meszely.de")
|
||||
$MailMessage.Subject = "SMTP test"
|
||||
$MailMessage.Body = "Ez egy teszt üzenet SMTP kapcsolat tesztelésére."
|
||||
|
||||
try {
|
||||
$SMTPClient.Send($MailMessage)
|
||||
Write-Host "E-Mail gesendet!"
|
||||
} catch {
|
||||
Write-Host "Fehler : $_"
|
||||
}
|
||||
24
Scripts/powershell/SMTP Tester.ps1
Normal file
24
Scripts/powershell/SMTP Tester.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
$SMTPServer = "smtp.office365.com" # Az SMTP szerver címe
|
||||
$SMTPPort = 587 # SMTP port (általában 587 a TLS-hez)
|
||||
$Username = "Bestellung-Fax-Eingang@aps-hh.de" # SMTP felhasználónév
|
||||
# $Password = "eXBd4zJQyVXicQk" # SMTP jelszó
|
||||
$Password = "YqhlR@H~cH%maNF" # SMTP jelszó
|
||||
|
||||
# SMTP kapcsolat létrehozása
|
||||
$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
|
||||
$SMTPClient.EnableSsl = $true # TLS engedélyezése
|
||||
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
|
||||
|
||||
# Teszt e-mail küldése
|
||||
$MailMessage = New-Object System.Net.Mail.MailMessage
|
||||
$MailMessage.From = "Bestellung-Fax-Eingang@aps-hh.de"
|
||||
$MailMessage.To.Add("istvan@meszely.de")
|
||||
$MailMessage.Subject = "SMTP test"
|
||||
$MailMessage.Body = "Ez egy teszt üzenet SMTP kapcsolat tesztelésére."
|
||||
|
||||
try {
|
||||
$SMTPClient.Send($MailMessage)
|
||||
Write-Host "E-Mail gesendet!"
|
||||
} catch {
|
||||
Write-Host "Fehler : $_"
|
||||
}
|
||||
4
Scripts/powershell/SNMP An auf Windows Server.ps1
Normal file
4
Scripts/powershell/SNMP An auf Windows Server.ps1
Normal file
@@ -0,0 +1,4 @@
|
||||
# SNMP An auf Windows Server
|
||||
Install-WindowsFeature -Name "SNMP-Service" -IncludeAllSubFeature -IncludeManagementTools
|
||||
# Firewall für SNMP Dienst öffnen
|
||||
New-NetFirewallRule -Name "SNMP" -DisplayName "Allow SNMP" -Protocol UDP -LocalPort 161 -Action Allow -Direction Inbound -RemoteAddress 10.102.1.59 -Profile Domain
|
||||
11
Scripts/powershell/Test-NetConnections.ps1
Normal file
11
Scripts/powershell/Test-NetConnections.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
Test-NetConnection srv-sharepoint.bhs.local -TraceRoute
|
||||
|
||||
Test-NetConnection -Port 80 srv-sharepoint.bhs.local
|
||||
|
||||
Test-NetConnection srv-sharepoint.bhs.local -DiagnoseRouting -InformationLevel Detailed
|
||||
|
||||
Apotheke:
|
||||
srv001.ham0489.apo.service-pt.de
|
||||
|
||||
Test-NetConnection -DiagnoseRouting -InformationLevel Detailed srv001.ham0489.apo.service-pt.de
|
||||
|
||||
34
Scripts/powershell/WMI Config.ps1
Normal file
34
Scripts/powershell/WMI Config.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
# WMI Config
|
||||
|
||||
netsh firewall set service RemoteAdmin enable
|
||||
|
||||
netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes
|
||||
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes
|
||||
|
||||
# Connection Testen
|
||||
$strComputer = "Computer_B"
|
||||
$colSettings = Get-WmiObject Win32_OperatingSystem -ComputerName $strComputer
|
||||
|
||||
strComputer = "Computer_B"
|
||||
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
|
||||
Set colSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
|
||||
|
||||
if ($colSettings) {
|
||||
Write-Host "WMI connection to $strComputer successful."
|
||||
} else {
|
||||
Write-Host "Failed to connect to WMI on $strComputer."
|
||||
}
|
||||
# WMI Test
|
||||
$wmiTest = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $strComputer
|
||||
if ($wmiTest) {
|
||||
Write-Host "WMI Test successful on $strComputer."
|
||||
} else {
|
||||
Write-Host "WMI Test failed on $strComputer."
|
||||
}
|
||||
# WMI Test with CIM
|
||||
$wmiTestCIM = Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $strComputer
|
||||
if ($wmiTestCIM) {
|
||||
Write-Host "CIM Test successful on $strComputer."
|
||||
} else {
|
||||
Write-Host "CIM Test failed on $strComputer."
|
||||
}
|
||||
5
Scripts/powershell/Wifi-netsh.ps1
Normal file
5
Scripts/powershell/Wifi-netsh.ps1
Normal file
@@ -0,0 +1,5 @@
|
||||
## Wifi
|
||||
# Show wlan Profiles
|
||||
netsh wlan show profiles
|
||||
# Show password von Wlan
|
||||
netsh wlan show profile name="WlanNet" key=clear
|
||||
24
Scripts/powershell/check_sharepoint_401.ps1
Normal file
24
Scripts/powershell/check_sharepoint_401.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
# SharePoint elérhetőség ellenőrzése - 401 válasz a cél
|
||||
$url = "http://srv-sharepoint.bhs.local"
|
||||
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -ErrorAction Stop
|
||||
$statusCode = $response.StatusCode
|
||||
} catch {
|
||||
# Ha kivétel van, akkor próbáljuk meg kiolvasni a státuszkódot a Response-tárgyból
|
||||
if ($_.Exception.Response) {
|
||||
$statusCode = $_.Exception.Response.StatusCode.Value__
|
||||
} else {
|
||||
Write-Host "2:Unbekannter Fehler: $($_.Exception.Message)"
|
||||
exit 2
|
||||
}
|
||||
}
|
||||
|
||||
if ($statusCode -eq 401) {
|
||||
Write-Host "0:SharePoint online, erwartete Antwort: 401 Unauthorized"
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "2:Unerwarteter HTTP-Statuscode: $statusCode"
|
||||
exit 2
|
||||
}
|
||||
87
Scripts/powershell/rdp_fehler_log.ps1
Normal file
87
Scripts/powershell/rdp_fehler_log.ps1
Normal file
@@ -0,0 +1,87 @@
|
||||
# $share = "\\aps-mysql01.aps.local\RdpLog\$env:COMPUTERNAME"
|
||||
|
||||
# Megosztott mappa a szerver neve szerint
|
||||
$share = "\\aps-mysql01.aps.local\RdpLog\$env:COMPUTERNAME"
|
||||
if (-not (Test-Path $share)) {
|
||||
New-Item -Path $share -ItemType Directory -Force
|
||||
}
|
||||
|
||||
# Funkció a logok kigyűjtésére
|
||||
function Get-RDPEvents {
|
||||
param (
|
||||
[string]$LogName,
|
||||
[int[]]$EventIDs
|
||||
)
|
||||
|
||||
Get-WinEvent -LogName $LogName |
|
||||
Where-Object { $_.Id -in $EventIDs } |
|
||||
ForEach-Object {
|
||||
$message = $_.Message
|
||||
$sessionID = $null
|
||||
$ursachencode = $null
|
||||
$userName = $null
|
||||
|
||||
# 1️⃣ SessionID és Ursachencode regexből
|
||||
if ($message -match "Sitzung ""?(\d+)""?.*Ursachencode: (\d+)") {
|
||||
$sessionID = [long]$matches[1]
|
||||
$ursachencode = [long]$matches[2]
|
||||
}
|
||||
elseif ($message -match 'Sitzungs-ID:\s*(\d+)') {
|
||||
$sessionID = [long]$matches[1]
|
||||
}
|
||||
|
||||
# 2️⃣ UserName: property[0]-ból
|
||||
if ($_.Properties.Count -ge 1 -and $_.Properties[0].Value -match "\S") {
|
||||
$userName = $_.Properties[0].Value
|
||||
}
|
||||
|
||||
# 3️⃣ Ha nincs property-ben, Message-ből APS\ mintával
|
||||
if (-not $userName -and $message -match '(APS\\[^\s"]+)') {
|
||||
$userName = $matches[1]
|
||||
}
|
||||
|
||||
# 4️⃣ 1149-es Event ID (auth) regex kiegészítés
|
||||
if (-not $userName -and $message -match 'Benutzer:\s*(\S+)') {
|
||||
$userName = $matches[1]
|
||||
}
|
||||
|
||||
[PSCustomObject]@{
|
||||
ServerName = $env:COMPUTERNAME
|
||||
LogName = $LogName
|
||||
EventID = $_.Id
|
||||
SessionID = $sessionID
|
||||
Ursachencode = $ursachencode
|
||||
Level = $_.LevelDisplayName
|
||||
UserName = $userName
|
||||
Message = $message
|
||||
TimeCreated = $_.TimeCreated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 1️⃣ UserName események (auth / reconnect) — SessionID-vel
|
||||
$userEvents = Get-RDPEvents -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" -EventIDs 24,25,1149
|
||||
|
||||
# 2️⃣ Disconnect események
|
||||
$disconnectEvents = Get-RDPEvents -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" -EventIDs 39,40
|
||||
|
||||
# 3️⃣ SessionID alapján hozzárendeljük a UserName-t a disconnect eseményekhez
|
||||
$disconnectEvents | ForEach-Object {
|
||||
$matchingUser = $userEvents | Where-Object { $_.SessionID -eq $_.SessionID } | Sort-Object TimeCreated -Descending | Select-Object -First 1
|
||||
if ($matchingUser) { $_.UserName = $matchingUser.UserName }
|
||||
}
|
||||
|
||||
# 4️⃣ Összesítés más logokkal
|
||||
$remoteEvents = Get-RDPEvents -LogName "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" -EventIDs 1006,1026
|
||||
$termDDEvents = Get-RDPEvents -LogName "System" -EventIDs 56 | Where-Object { $_.Message -like "*TermDD*" }
|
||||
$brokerClientEvents = Get-RDPEvents -LogName "Microsoft-Windows-TerminalServices-SessionBroker-Client/Operational" -EventIDs 1000,1001
|
||||
$brokerManagerEvents = Get-RDPEvents -LogName "Microsoft-Windows-TerminalServices-SessionBroker-Manager/Operational" -EventIDs 1000,1001
|
||||
|
||||
# 5️⃣ Összesítés
|
||||
$allEvents = $userEvents + $disconnectEvents + $remoteEvents + $termDDEvents + $brokerClientEvents + $brokerManagerEvents
|
||||
|
||||
# CSV-be mentés
|
||||
$filename = Join-Path $share ("RDP_Log_" + (Get-Date -Format "yyyyMMdd_HHmmss") + ".csv")
|
||||
$allEvents | Export-Csv $filename -NoTypeInformation -Encoding UTF8
|
||||
|
||||
Write-Host "RDP log export kész: $filename"
|
||||
61
Scripts/powershell/rdp_fehler_log_sammlung.ps1
Normal file
61
Scripts/powershell/rdp_fehler_log_sammlung.ps1
Normal file
@@ -0,0 +1,61 @@
|
||||
# MySQL kapcsolati adatok
|
||||
# Install-PackageProvider -Name NuGet -Force
|
||||
# Register-PackageSource -Name NuGet -Location https://www.nuget.org/api/v2/ -ProviderName NuGet -Trusted
|
||||
# Install-Package MySql.Data -Force
|
||||
# Oder : https://dev.mysql.com/downloads/connector/net/
|
||||
|
||||
$mysqlServer = "localhost" # vagy a szerver IP/cím
|
||||
$mysqlDatabase = "rdp_log" # az adatbázis neve
|
||||
$mysqlUser = "rdplog" # felhasználónév
|
||||
$mysqlPassword = "Test123#" # jelszó
|
||||
|
||||
# Forrás és célmappa
|
||||
$sourceFolder = "C:\RdpLog\Logs" # a mappa, ahol a CSV fájlok vannak
|
||||
$destinationFolder = "C:\RdpLog\Archive" # a mappa, ahova áthelyezzük a feldolgozott fájlokat
|
||||
|
||||
# MySQL kapcsolódás
|
||||
Add-Type -Path "C:\Program Files\PackageManagement\NuGet\Packages\MySql.Data.9.4.0\lib\net9.0\MySql.Data.dll" # cseréld le a valós útvonalra!
|
||||
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection
|
||||
$connection.ConnectionString = "server=$mysqlServer;database=$mysqlDatabase;uid=$mysqlUser;pwd=$mysqlPassword;"
|
||||
$connection.Open()
|
||||
|
||||
# Minden CSV fájl feldolgozása
|
||||
Get-ChildItem -Path $sourceFolder -Filter "*.csv" | ForEach-Object {
|
||||
$csvPath = $_.FullName
|
||||
$csvData = Import-Csv -Path $csvPath -Delimiter "," -Encoding UTF8
|
||||
|
||||
Write-Host "Feldolgozás alatt: $csvPath"
|
||||
|
||||
# Adatok feltöltése az adatbázisba
|
||||
foreach ($row in $csvData) {
|
||||
$query = "INSERT INTO rdplog (ServerName, LogName, EventID, SessionID, Ursachencode, Level, UserName, Message, TimeCreated) VALUES (@ServerName, @LogName, @EventID, @SessionID, @Ursachencode, @Level, @UserName, @Message, @TimeCreated)"
|
||||
|
||||
$command = New-Object MySql.Data.MySqlClient.MySqlCommand($query, $connection)
|
||||
|
||||
# Paraméterek hozzáadása
|
||||
$command.Parameters.AddWithValue("@ServerName", $row.ServerName) | Out-Null
|
||||
$command.Parameters.AddWithValue("@LogName", $row.LogName) | Out-Null
|
||||
$command.Parameters.AddWithValue("@EventID", $row.EventID) | Out-Null
|
||||
$command.Parameters.AddWithValue("@SessionID", $row.SessionID) | Out-Null
|
||||
$command.Parameters.AddWithValue("@Ursachencode", $row.Ursachencode) | Out-Null
|
||||
$command.Parameters.AddWithValue("@Level", $row.Level) | Out-Null
|
||||
$command.Parameters.AddWithValue("@UserName", $row.UserName) | Out-Null
|
||||
$command.Parameters.AddWithValue("@Message", $row.Message) | Out-Null
|
||||
|
||||
# TimeCreated átalakítása (ha szükséges)
|
||||
$timeCreated = [datetime]::ParseExact($row.TimeCreated, "dd.MM.yyyy HH:mm:ss", $null)
|
||||
$command.Parameters.AddWithValue("@TimeCreated", $timeCreated) | Out-Null
|
||||
|
||||
# Lekérdezés végrehajtása
|
||||
$command.ExecuteNonQuery() | Out-Null
|
||||
}
|
||||
|
||||
# Fájl áthelyezése a célmappába
|
||||
Move-Item -Path $csvPath -Destination $destinationFolder -Force
|
||||
Write-Host "Fájl áthelyezve: $csvPath -> $destinationFolder"
|
||||
}
|
||||
|
||||
# Kapcsolat bezárása
|
||||
$connection.Close()
|
||||
|
||||
Write-Host "Minden fájl sikeresen feldolgozva és áthelyezve!"
|
||||
18
Scripts/powershell/snmp_command.ps1
Normal file
18
Scripts/powershell/snmp_command.ps1
Normal file
@@ -0,0 +1,18 @@
|
||||
# Sophos SNMP lekérdezések VPN nevekhez
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.4.3
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.4.4
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.4.5 # Telekom
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.4.6 # Kapelou
|
||||
# Sophos SNMP lekérdezések VPN értékekhez
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.9.3
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.9.4
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.9.5 # Telekom Wert
|
||||
Get-SnmpData -IP 10.102.1.1 -Community prtg -OID 1.3.6.1.4.1.2604.5.1.6.1.1.1.1.9.6 # Kapelou wert
|
||||
|
||||
# Cisco 9200
|
||||
Get-SnmpData -IP 10.102.1.61 -Community prtg -OID 1.3.6.1.2.1.2.2.1.2
|
||||
Get-SnmpData -IP 10.102.1.61 -Community prtg -OID 1.3.6.1.2.1.31.1.1.1.1
|
||||
Get-SnmpData -IP 10.102.1.61 -Community prtg -OID 1.3.6.1.2.1.2.2.1.2.13
|
||||
|
||||
|
||||
|
||||
24
Scripts/python/folder_list.py
Normal file
24
Scripts/python/folder_list.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import imaplib
|
||||
|
||||
# ===== Einstellungen =====
|
||||
IMAP_SERVER = "aps-exch01.aps.local"
|
||||
IMAP_PORT = 993
|
||||
USERNAME = "svc.fax_bestellung@aps-hh.de"
|
||||
PASSWORD = "UyCcxoP8J^3yllLN/m*5"
|
||||
# USERNAME = "i.meszely@aps-hh.de"
|
||||
# PASSWORD = "virgI6774#Maci"
|
||||
# IMAP-Verbindung aufbauen
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Alle verfügbaren Mailboxen/Mappen listen
|
||||
status, folders = mail.list()
|
||||
if status == "OK":
|
||||
print("Verfügbare Ordner/Mailboxen:")
|
||||
for folder in folders:
|
||||
print(folder.decode())
|
||||
else:
|
||||
print("Fehler beim Abrufen der Ordnerliste.")
|
||||
|
||||
# Verbindung schließen
|
||||
mail.logout()
|
||||
@@ -0,0 +1,92 @@
|
||||
import imaplib
|
||||
import email
|
||||
import os
|
||||
from email.header import decode_header
|
||||
|
||||
# ===== Einstellungen =====
|
||||
IMAP_SERVER = "aps-exch01.aps.local" # IMAP-Server-Adresse
|
||||
IMAP_PORT = 993 # IMAP-SSL-Port
|
||||
USERNAME = "i.meszely@aps-hh.de" # Benutzername / E-Mail-Adresse
|
||||
PASSWORD = "virgI6774#Maci" # Passwort
|
||||
MAILBOX = "INBOX" # Ordnername (z. B. "INBOX" oder "HelpDesk")
|
||||
PROCESSED_FOLDER = "erledigt" # Zielordner für verarbeitete E-Mails
|
||||
DOWNLOAD_DIR = r"C:\Downloads" # Speicherort für PDFs
|
||||
|
||||
# Verbindung herstellen
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Ordner auswählen
|
||||
mail.select(MAILBOX)
|
||||
|
||||
# Alle Nachrichten suchen (hier: alle E-Mails)
|
||||
status, messages = mail.search(None, "ALL")
|
||||
if status != "OK":
|
||||
print("Fehler beim Abrufen der Nachrichtenliste")
|
||||
mail.logout()
|
||||
exit()
|
||||
|
||||
# Liste für zu löschende Nachrichten
|
||||
delete_list = []
|
||||
|
||||
# Nachrichten verarbeiten
|
||||
for num in messages[0].split():
|
||||
try:
|
||||
# Nachricht abrufen
|
||||
status, data = mail.fetch(num, "(RFC822)")
|
||||
if status != "OK":
|
||||
print(f"Fehler beim Herunterladen der Nachricht {num}")
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
pdf_found = False
|
||||
|
||||
# Betreff dekodieren
|
||||
subject, encoding = decode_header(msg["Subject"])[0]
|
||||
if isinstance(subject, bytes):
|
||||
subject = subject.decode(encoding if encoding else "utf-8", errors="replace")
|
||||
|
||||
print(f"Verarbeite E-Mail: {subject}")
|
||||
|
||||
# Anhänge prüfen
|
||||
for part in msg.walk():
|
||||
if part.get_content_maintype() == "multipart":
|
||||
continue
|
||||
if part.get("Content-Disposition") is None:
|
||||
continue
|
||||
|
||||
filename = part.get_filename()
|
||||
if filename:
|
||||
decoded_name, enc = decode_header(filename)[0]
|
||||
if isinstance(decoded_name, bytes):
|
||||
decoded_name = decoded_name.decode(enc if enc else "utf-8", errors="replace")
|
||||
|
||||
# Ungültige Zeichen im Dateinamen ersetzen
|
||||
safe_filename = "".join(c if c.isalnum() or c in (" ", ".", "_", "-") else "_" for c in decoded_name)
|
||||
|
||||
if safe_filename.lower().endswith(".pdf"):
|
||||
filepath = os.path.join(DOWNLOAD_DIR, safe_filename)
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(part.get_payload(decode=True))
|
||||
print(f"PDF gespeichert: {filepath}")
|
||||
pdf_found = True
|
||||
|
||||
# Falls PDF gefunden → in Zielordner verschieben & später löschen
|
||||
if pdf_found:
|
||||
result = mail.copy(num, PROCESSED_FOLDER)
|
||||
if result[0] == "OK":
|
||||
delete_list.append(num)
|
||||
else:
|
||||
print(f"Fehler beim Verschieben der Nachricht {num}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Verarbeiten der Nachricht {num}: {e}")
|
||||
|
||||
# Nach der Verarbeitung: löschen
|
||||
for num in delete_list:
|
||||
mail.store(num, "+FLAGS", "\\Deleted")
|
||||
mail.expunge()
|
||||
|
||||
# Verbindung trennen
|
||||
mail.logout()
|
||||
print("Fertig! Alle neuen PDFs wurden heruntergeladen und verarbeitet.")
|
||||
93
Scripts/python/import_pfd_de_v.0.2.panda.py
Normal file
93
Scripts/python/import_pfd_de_v.0.2.panda.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import imaplib
|
||||
import email
|
||||
import os
|
||||
from email.header import decode_header
|
||||
|
||||
# ===== Einstellungen =====
|
||||
IMAP_SERVER = "aps-exch01.aps.local" # IMAP-Server-Adresse
|
||||
IMAP_PORT = 993 # IMAP-SSL-Port
|
||||
USERNAME = "i.meszely@aps-hh.de" # Benutzername / E-Mail-Adresse
|
||||
PASSWORD = "virgI6774#Maci" # Passwort
|
||||
# MAILBOX = 'HelpDesk/Inbox' # Der zu verwendende Ordner
|
||||
MAILBOX = "INBOX" # Ordnername (z. B. "INBOX" oder "HelpDesk")
|
||||
PROCESSED_FOLDER = "erledigt" # Zielordner für verarbeitete E-Mails
|
||||
DOWNLOAD_DIR = r"\\aps-nb090\Test" # Speicherort für PDFs
|
||||
|
||||
# Verbindung herstellen
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Ordner auswählen
|
||||
mail.select(MAILBOX)
|
||||
|
||||
# Alle Nachrichten suchen (hier: alle E-Mails)
|
||||
status, messages = mail.search(None, "ALL")
|
||||
if status != "OK":
|
||||
print("Fehler beim Abrufen der Nachrichtenliste")
|
||||
mail.logout()
|
||||
exit()
|
||||
|
||||
# Liste für zu löschende Nachrichten
|
||||
delete_list = []
|
||||
|
||||
# Nachrichten verarbeiten
|
||||
for num in messages[0].split():
|
||||
try:
|
||||
# Nachricht abrufen
|
||||
status, data = mail.fetch(num, "(RFC822)")
|
||||
if status != "OK":
|
||||
print(f"Fehler beim Herunterladen der Nachricht {num}")
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
pdf_found = False
|
||||
|
||||
# Betreff dekodieren
|
||||
subject, encoding = decode_header(msg["Subject"])[0]
|
||||
if isinstance(subject, bytes):
|
||||
subject = subject.decode(encoding if encoding else "utf-8", errors="replace")
|
||||
|
||||
print(f"Verarbeite E-Mail: {subject}")
|
||||
|
||||
# Anhänge prüfen
|
||||
for part in msg.walk():
|
||||
if part.get_content_maintype() == "multipart":
|
||||
continue
|
||||
if part.get("Content-Disposition") is None:
|
||||
continue
|
||||
|
||||
filename = part.get_filename()
|
||||
if filename:
|
||||
decoded_name, enc = decode_header(filename)[0]
|
||||
if isinstance(decoded_name, bytes):
|
||||
decoded_name = decoded_name.decode(enc if enc else "utf-8", errors="replace")
|
||||
|
||||
# Ungültige Zeichen im Dateinamen ersetzen
|
||||
safe_filename = "".join(c if c.isalnum() or c in (" ", ".", "_", "-") else "_" for c in decoded_name)
|
||||
|
||||
if safe_filename.lower().endswith(".pdf"):
|
||||
filepath = os.path.join(DOWNLOAD_DIR, safe_filename)
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(part.get_payload(decode=True))
|
||||
print(f"PDF gespeichert: {filepath}")
|
||||
pdf_found = True
|
||||
|
||||
# Falls PDF gefunden → in Zielordner verschieben & später löschen
|
||||
if pdf_found:
|
||||
result = mail.copy(num, PROCESSED_FOLDER)
|
||||
if result[0] == "OK":
|
||||
delete_list.append(num)
|
||||
else:
|
||||
print(f"Fehler beim Verschieben der Nachricht {num}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Verarbeiten der Nachricht {num}: {e}")
|
||||
|
||||
# Nach der Verarbeitung: löschen
|
||||
for num in delete_list:
|
||||
mail.store(num, "+FLAGS", "\\Deleted")
|
||||
mail.expunge()
|
||||
|
||||
# Verbindung trennen
|
||||
mail.logout()
|
||||
print("Fertig! Alle neuen PDFs wurden heruntergeladen und verarbeitet.")
|
||||
93
Scripts/python/import_pfd_de_v.0.2.py
Normal file
93
Scripts/python/import_pfd_de_v.0.2.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import imaplib
|
||||
import email
|
||||
import os
|
||||
from email.header import decode_header
|
||||
|
||||
# ===== Einstellungen =====
|
||||
IMAP_SERVER = "aps-exch01.aps.local" # IMAP-Server-Adresse
|
||||
IMAP_PORT = 993 # IMAP-SSL-Port
|
||||
USERNAME = "Bestellung-Fax-Eingang@aps-hh.de" # Benutzername / E-Mail-Adresse
|
||||
PASSWORD = "kX%tTFC~ZR!;S#Q~h!T^22" # Passwort
|
||||
# MAILBOX = 'HelpDesk/Inbox' # Der zu verwendende Ordner
|
||||
MAILBOX = "INBOX" # Ordnername (z. B. "INBOX" oder "HelpDesk")
|
||||
PROCESSED_FOLDER = "erledigt" # Zielordner für verarbeitete E-Mails
|
||||
DOWNLOAD_DIR = r"\\aps-nb090\test" # Speicherort für PDFs
|
||||
|
||||
# Verbindung herstellen
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Ordner auswählen
|
||||
mail.select(MAILBOX)
|
||||
|
||||
# Alle Nachrichten suchen (hier: alle E-Mails)
|
||||
status, messages = mail.search(None, "ALL")
|
||||
if status != "OK":
|
||||
print("Fehler beim Abrufen der Nachrichtenliste")
|
||||
mail.logout()
|
||||
exit()
|
||||
|
||||
# Liste für zu löschende Nachrichten
|
||||
delete_list = []
|
||||
|
||||
# Nachrichten verarbeiten
|
||||
for num in messages[0].split():
|
||||
try:
|
||||
# Nachricht abrufen
|
||||
status, data = mail.fetch(num, "(RFC822)")
|
||||
if status != "OK":
|
||||
print(f"Fehler beim Herunterladen der Nachricht {num}")
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
pdf_found = False
|
||||
|
||||
# Betreff dekodieren
|
||||
subject, encoding = decode_header(msg["Subject"])[0]
|
||||
if isinstance(subject, bytes):
|
||||
subject = subject.decode(encoding if encoding else "utf-8", errors="replace")
|
||||
|
||||
print(f"Verarbeite E-Mail: {subject}")
|
||||
|
||||
# Anhänge prüfen
|
||||
for part in msg.walk():
|
||||
if part.get_content_maintype() == "multipart":
|
||||
continue
|
||||
if part.get("Content-Disposition") is None:
|
||||
continue
|
||||
|
||||
filename = part.get_filename()
|
||||
if filename:
|
||||
decoded_name, enc = decode_header(filename)[0]
|
||||
if isinstance(decoded_name, bytes):
|
||||
decoded_name = decoded_name.decode(enc if enc else "utf-8", errors="replace")
|
||||
|
||||
# Ungültige Zeichen im Dateinamen ersetzen
|
||||
safe_filename = "".join(c if c.isalnum() or c in (" ", ".", "_", "-") else "_" for c in decoded_name)
|
||||
|
||||
if safe_filename.lower().endswith(".pdf"):
|
||||
filepath = os.path.join(DOWNLOAD_DIR, safe_filename)
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(part.get_payload(decode=True))
|
||||
print(f"PDF gespeichert: {filepath}")
|
||||
pdf_found = True
|
||||
|
||||
# Falls PDF gefunden → in Zielordner verschieben & später löschen
|
||||
if pdf_found:
|
||||
result = mail.copy(num, PROCESSED_FOLDER)
|
||||
if result[0] == "OK":
|
||||
delete_list.append(num)
|
||||
else:
|
||||
print(f"Fehler beim Verschieben der Nachricht {num}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Verarbeiten der Nachricht {num}: {e}")
|
||||
|
||||
# Nach der Verarbeitung: löschen
|
||||
for num in delete_list:
|
||||
mail.store(num, "+FLAGS", "\\Deleted")
|
||||
mail.expunge()
|
||||
|
||||
# Verbindung trennen
|
||||
mail.logout()
|
||||
print("Fertig! Alle neuen PDFs wurden heruntergeladen und verarbeitet.")
|
||||
44
Scripts/python/pdf_import.py
Normal file
44
Scripts/python/pdf_import.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import imaplib
|
||||
import email
|
||||
import os
|
||||
|
||||
# IMAP szerver és hitelesítés
|
||||
IMAP_SERVER = "aps-exch01.aps.local"
|
||||
IMAP_PORT = 993
|
||||
USERNAME = "i.meszely@aps-hh.de"
|
||||
PASSWORD = "virgI6774#Maci"
|
||||
DOWNLOAD_DIR = r"C:\Downloads"
|
||||
|
||||
if not os.path.exists(DOWNLOAD_DIR):
|
||||
os.makedirs(DOWNLOAD_DIR)
|
||||
|
||||
# Kapcsolódás IMAP SSL-lel
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Beérkezett üzenetek mappa kiválasztása
|
||||
mail.select("INBOX")
|
||||
|
||||
# Csak olvasatlan levelek keresése
|
||||
status, messages = mail.search(None, '(UNSEEN)')
|
||||
|
||||
if status == "OK":
|
||||
for num in messages[0].split():
|
||||
status, data = mail.fetch(num, "(RFC822)")
|
||||
if status != "OK":
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
|
||||
for part in msg.walk():
|
||||
if part.get_content_type() == "application/pdf":
|
||||
filename = part.get_filename()
|
||||
if filename:
|
||||
filepath = os.path.join(DOWNLOAD_DIR, filename)
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(part.get_payload(decode=True))
|
||||
print(f"Letöltve: {filepath}")
|
||||
|
||||
# Kapcsolat bontása
|
||||
mail.close()
|
||||
mail.logout()
|
||||
64
Scripts/python/pdf_import_allemail_und_vershoben.py
Normal file
64
Scripts/python/pdf_import_allemail_und_vershoben.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import imaplib
|
||||
import email
|
||||
import os
|
||||
|
||||
# ===== Beállítások =====
|
||||
IMAP_SERVER = "imap.szervered.hu"
|
||||
IMAP_PORT = 993
|
||||
USERNAME = "felhasznalo@domain.hu"
|
||||
PASSWORD = "jelszo"
|
||||
DOWNLOAD_DIR = r"C:\Downloads"
|
||||
PROCESSED_FOLDER = "fertig" # almappa neve az INBOX-ban
|
||||
|
||||
# Letöltési mappa létrehozása, ha nem létezik
|
||||
if not os.path.exists(DOWNLOAD_DIR):
|
||||
os.makedirs(DOWNLOAD_DIR)
|
||||
|
||||
# IMAP csatlakozás
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(USERNAME, PASSWORD)
|
||||
|
||||
# Beérkezett üzenetek mappa kiválasztása
|
||||
mail.select("INBOX")
|
||||
|
||||
# Minden levél ID-jának lekérése
|
||||
status, messages = mail.search(None, "ALL")
|
||||
if status != "OK":
|
||||
print("Nem sikerült lekérni az üzeneteket.")
|
||||
mail.logout()
|
||||
exit()
|
||||
|
||||
# Ellenőrizzük, hogy létezik-e a 'fertig' mappa, ha nem, létrehozzuk
|
||||
mail.create(PROCESSED_FOLDER)
|
||||
|
||||
# Minden levél feldolgozása
|
||||
for num in messages[0].split():
|
||||
status, data = mail.fetch(num, "(RFC822)")
|
||||
if status != "OK":
|
||||
print(f"Hiba az {num} üzenet letöltésekor.")
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
pdf_found = False
|
||||
|
||||
for part in msg.walk():
|
||||
if part.get_content_type() == "application/pdf":
|
||||
filename = part.get_filename()
|
||||
if filename:
|
||||
filepath = os.path.join(DOWNLOAD_DIR, filename)
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(part.get_payload(decode=True))
|
||||
print(f"Letöltve: {filepath}")
|
||||
pdf_found = True
|
||||
|
||||
# Ha volt PDF, akkor a levelet áthelyezzük a 'fertig' mappába
|
||||
if pdf_found:
|
||||
result = mail.copy(num, PROCESSED_FOLDER)
|
||||
if result[0] == "OK":
|
||||
mail.store(num, "+FLAGS", "\\Deleted")
|
||||
mail.expunge()
|
||||
print(f"Levél áthelyezve a '{PROCESSED_FOLDER}' mappába.")
|
||||
|
||||
# Kapcsolat bontása
|
||||
mail.close()
|
||||
mail.logout()
|
||||
30
Scripts/regkey/Disable_TLS1.0_ud_1.1.reg
Normal file
30
Scripts/regkey/Disable_TLS1.0_ud_1.1.reg
Normal file
@@ -0,0 +1,30 @@
|
||||
# To force enable TLS 1.2, add the registry entries below:
|
||||
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
|
||||
"DisabledByDefault"=dword:00000000
|
||||
"Enabled"=dword:00000001
|
||||
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
|
||||
"DisabledByDefault"=dword:00000000
|
||||
"Enabled"=dword:00000001
|
||||
|
||||
# To enable system encryption protocols for .Net 3.5 and 2.0:
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
|
||||
"SystemDefaultTlsVersions"=dword:00000001
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
|
||||
"SchUseStrongCrypto"=dword:00000001
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
|
||||
"SystemDefaultTlsVersions"=dword:00000001
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
|
||||
"SchUseStrongCrypto"=dword:00000001
|
||||
|
||||
# For .Net 4.x:
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
|
||||
"SystemDefaultTlsVersions"=dword:00000001
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
|
||||
"SystemDefaultTlsVersions"=dword:00000001
|
||||
|
||||
# To enable using TLS 1.2 for WinHTTP:
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
|
||||
"DefaultSecureProtocols"=dword:00000800
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
|
||||
"DefaultSecureProtocols"=dword:00000800
|
||||
|
||||
10
Scripts/sql/CREATE DATABASE drucklog;.sql
Normal file
10
Scripts/sql/CREATE DATABASE drucklog;.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE DATABASE drucklog;
|
||||
CREATE USER IF NOT EXIST 'druckloguser'@'%' IDENTIFIED BY 'Test123#';
|
||||
SELECT user, host FROM mysql.user;
|
||||
GRANT ALL PRIVILEGES ON drucklog.* TO 'druckloguser'@'%';
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT;
|
||||
|
||||
|
||||
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'eprencs';
|
||||
FLUSH PRIVILEGES;
|
||||
14
Scripts/sql/CREATE TABLE drucklog.sql
Normal file
14
Scripts/sql/CREATE TABLE drucklog.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE drucklog (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
event_id BIGINT,
|
||||
datum DATETIME,
|
||||
tag DATE,
|
||||
woche INT,
|
||||
benutzer VARCHAR(100),
|
||||
computer VARCHAR(100),
|
||||
dokument VARCHAR(255),
|
||||
drucker VARCHAR(255),
|
||||
seiten INT,
|
||||
quelle_server VARCHAR(100),
|
||||
UNIQUE KEY(event_id, quelle_server)
|
||||
);
|
||||
80
Scripts/sql/Statistik.sql
Normal file
80
Scripts/sql/Statistik.sql
Normal file
@@ -0,0 +1,80 @@
|
||||
-- Nach Druckern sortierte Druckstatistik
|
||||
SELECT
|
||||
drucker AS `Drucker`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY drucker
|
||||
ORDER BY `Alle Seiten` DESC;
|
||||
|
||||
-- Tägliche Druckstatistik
|
||||
SELECT
|
||||
DATE(datum) AS `Datum`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE(datum)
|
||||
ORDER BY `Datum`;
|
||||
|
||||
-- Täglich nach Drucker sortierte Druckstatistik
|
||||
SELECT
|
||||
DATE(datum) AS `Datum`,
|
||||
drucker AS `Drucker`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE(datum), drucker
|
||||
ORDER BY `Datum`, `Drucker`;
|
||||
|
||||
-- Wöchentlich Druckstatistik
|
||||
SELECT
|
||||
DATE_FORMAT(datum, '%Y-%u') AS `Woche`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE_FORMAT(datum, '%Y-%u')
|
||||
ORDER BY `Woche`;
|
||||
|
||||
-- Wöchentlich nach Drucker sortierte Druckstatistik
|
||||
SELECT
|
||||
DATE_FORMAT(datum, '%Y-%u') AS `Woche`,
|
||||
drucker AS `Drucker`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE_FORMAT(datum, '%Y-%u'), drucker
|
||||
ORDER BY `Woche`, `Drucker`;
|
||||
|
||||
-- Tägliche Druckstatistik für einen bestimmten Drucker
|
||||
SELECT
|
||||
DATE(datum) AS `Datum`,
|
||||
drucker AS `Drucker`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
WHERE drucker = 'NYOMTATO_NEVE'
|
||||
AND DATE(datum) = CURDATE()
|
||||
GROUP BY DATE(datum), drucker;
|
||||
|
||||
-- Täglich nach Rechner sortierte Druckstatistik
|
||||
SELECT
|
||||
DATE(datum) AS `Datum`,
|
||||
rechner AS `Rechner`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE(datum), rechner
|
||||
ORDER BY `Datum`, `Rechner`;
|
||||
|
||||
-- Monatliche Druckstatistik venigsten gedrucht Seiten
|
||||
SELECT
|
||||
DATE_FORMAT(datum, '%Y-%m') AS `Monat`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
GROUP BY DATE_FORMAT(datum, '%Y-%m')
|
||||
ORDER BY `Alle Seiten` ASC
|
||||
LIMIT 9;
|
||||
|
||||
-- Nach Druckern sortierte Druckstatistik ( auser paar Drucker )
|
||||
SELECT
|
||||
drucker AS `Drucker`,
|
||||
SUM(seiten) AS `Alle Seiten`
|
||||
FROM drucklog
|
||||
WHERE drucker NOT IN ('Elbe Fach 2', 'Elbe Fach A', 'Elbe Fach B', 'Elbe Fach 1', 'Weser Fach 4', 'Weser Fach 7', 'Elbe Fach 7')
|
||||
GROUP BY drucker
|
||||
ORDER BY `Alle Seiten` ASC
|
||||
LIMIT 10;
|
||||
|
||||
73
Scripts/sql/pstgresql_matrix.sql
Normal file
73
Scripts/sql/pstgresql_matrix.sql
Normal file
@@ -0,0 +1,73 @@
|
||||
1. PostgreSQL VM (adatbázis)
|
||||
Hostname: postresq.home.meszely.eu
|
||||
|
||||
apt update && apt upgrade -y
|
||||
apt install -y postgresql
|
||||
|
||||
CREATE USER synapse WITH PASSWORD 'soseTudodMegMertNemMondomMeg';
|
||||
CREATE DATABASE synapse OWNER synapse ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0;
|
||||
|
||||
|
||||
#A postgresql.conf -ban engedélyezs a tävoli hozzäférést.
|
||||
listen_addresses = '*'
|
||||
# Itt engedélyezd a belsö hälozati VMek IP-jét.
|
||||
pg_hba.conf
|
||||
|
||||
2. Synapse VM (Matrix szerver)
|
||||
apt update && apt upgrade -y
|
||||
apt install -y lsb-release wget apt-transport-https
|
||||
wget -qO - https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg | sudo tee /usr/share/keyrings/matrix-org-archive-keyring.gpg
|
||||
echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/matrix-org.list
|
||||
apt update
|
||||
apt install -y matrix-synapse-py3
|
||||
|
||||
|
||||
Konfiguráció:
|
||||
|
||||
Server name: pl. matrix.sajatdomain.hu
|
||||
|
||||
Database: PostgreSQL → add meg a Postgres VM IP-jét, adatbázist, felhasználót.
|
||||
|
||||
Kikapcsolhatod a federationt, ha csak családnak akarod:
|
||||
|
||||
homeserver.yaml → federation_domain_whitelist: []
|
||||
|
||||
3. Nginx Reverse Proxy VM
|
||||
|
||||
apt update && apt upgrade -y
|
||||
apt install -y nginx certbot python3-certbot-nginx
|
||||
|
||||
Konfiguráció:
|
||||
|
||||
Egy host conf a Matrixnak (pl. /etc/nginx/sites-available/matrix.sajatdomain.hu):
|
||||
|
||||
server {
|
||||
server_name matrix.sajatdomain.hu;
|
||||
|
||||
location / {
|
||||
proxy_pass http://SYNAPSE_VM_IP:8008;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
|
||||
ln -s /etc/nginx/sites-available/matrix.sajatdomain.hu /etc/nginx/sites-enabled/
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
|
||||
certbot --nginx -d matrix.sajatdomain.hu
|
||||
|
||||
4. Első belépés
|
||||
|
||||
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008
|
||||
|
||||
Ezzel tudsz belépni pl. az Element kliensből.
|
||||
Később a családtagokat is te hozod létre.
|
||||
|
||||
5. Opcionális bővítések
|
||||
|
||||
Element Web vagy Element Docker külön VM-en → webes kliens.
|
||||
Botok (pl. naptár emlékeztető, bridge Discord/Telegram felé).
|
||||
Monitoring (pl. Prometheus exporter a Synapse-hoz).
|
||||
|
||||
|
||||
14
Scripts/sql/query-tab-2025-07-29_11-12-43-724.sql
Normal file
14
Scripts/sql/query-tab-2025-07-29_11-12-43-724.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE drucklog (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
event_id BIGINT,
|
||||
datum DATETIME,
|
||||
tag DATE,
|
||||
woche INT,
|
||||
benutzer VARCHAR(100),
|
||||
computer VARCHAR(100),
|
||||
dokument VARCHAR(255),
|
||||
drucker VARCHAR(255),
|
||||
seiten INT,
|
||||
quelle_server VARCHAR(100),
|
||||
UNIQUE KEY(event_id, quelle_server)
|
||||
);
|
||||
Reference in New Issue
Block a user