add skripts
This commit is contained in:
parent
901214e9bc
commit
caef0613ce
16
README.md
16
README.md
@ -1,2 +1,18 @@
|
|||||||
# shell-scripts
|
# shell-scripts
|
||||||
|
|
||||||
|
os_generic: generell fürs os gültige scripte
|
||||||
|
os_special: skripte für spezielle Hardware
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Generic Debian Scripts examples:
|
||||||
|
|
||||||
|
network_interfaces_dhcp_rollout.sh [-f interfaces-file] [-i interface] [-i interface2] ...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
csv_collum_join.ps -> 2. Spalte einer csv zusammenführen und als Datei ausgeben (ausser erste Zeile)
|
||||||
|
scan_host_network.ps -> Das subnetz des Hosts scannen
|
||||||
|
uninstall_install_history.ps
|
||||||
235
bash/generic/network_interfaces_dhcp_rollout.sh
Normal file
235
bash/generic/network_interfaces_dhcp_rollout.sh
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ein kleines Skript dass:
|
||||||
|
# 1. Dateien erstellt, die den Namen der Network-Interfaces an ihren pci-path binden
|
||||||
|
# 2. Die /etc/network/interfaces auskommentiert falls dort unbekannte interfaces stehen
|
||||||
|
# 3. alle definierten Interfaces + loopback in die /etc/network/interfaces schreibt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Standardwert für Interfaces (wenn keine übergeben werden)
|
||||||
|
interfaces=()
|
||||||
|
iface_file="/etc/network/interfaces"
|
||||||
|
name_dir="/etc/systemd/network"
|
||||||
|
|
||||||
|
# Verarbeite die übergebenen Shortflags
|
||||||
|
while getopts "i:f:" opt; do
|
||||||
|
case $opt in
|
||||||
|
i)
|
||||||
|
interfaces+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
iface_file="$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 [-f interfaces-file] [-i interface] [-i interface2] ..."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Wenn keine Interfaces übergeben wurden, nutze Standard-Interfaces
|
||||||
|
if [ ${#interfaces[@]} -eq 0 ]; then
|
||||||
|
interfaces=("eno1")
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# echo "Die Links für die Interfacenamen werden erstellt:"
|
||||||
|
# # Hier werden die Interface-Namen mit ihren Bussen gelinkt -> einheitlich, persistente Bennenung
|
||||||
|
# create_link_file() {
|
||||||
|
# local file="$name_dir/$1"
|
||||||
|
# local content="$2"
|
||||||
|
|
||||||
|
# if [[ -f "$file" ]]; then
|
||||||
|
# if diff -q <(printf "%s\n" "$content") "$file" >/dev/null; then
|
||||||
|
# echo "✔ $file existiert bereits und ist korrekt"
|
||||||
|
# return
|
||||||
|
# else
|
||||||
|
# echo "↺ $file existiert, Inhalt unterscheidet sich – aktualisiere"
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# echo "➕ $file existiert nicht – erstelle"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# printf "%s\n" "$content" > "$file"
|
||||||
|
# }
|
||||||
|
|
||||||
|
# # # Erstelle Links für alle Interfaces
|
||||||
|
# # for iface in "${interfaces[@]}"; do
|
||||||
|
# # create_link_file "10-$iface.link" \
|
||||||
|
# # "[Match]
|
||||||
|
# # Path=pci-0000:06:00.1
|
||||||
|
|
||||||
|
# # [Link]
|
||||||
|
# # Name=$iface"
|
||||||
|
# # done
|
||||||
|
|
||||||
|
# create_link_file "10-eno2.link" \
|
||||||
|
# "[Match]
|
||||||
|
# Path=pci-0000:06:00.1
|
||||||
|
|
||||||
|
# [Link]
|
||||||
|
# Name=eno2"
|
||||||
|
|
||||||
|
# create_link_file "10-eno3.link" \
|
||||||
|
# "[Match]
|
||||||
|
# Path=pci-0000:06:00.2
|
||||||
|
|
||||||
|
# [Link]
|
||||||
|
# Name=eno3"
|
||||||
|
|
||||||
|
# create_link_file "10-eno4.link" \
|
||||||
|
# "[Match]
|
||||||
|
# Path=pci-0000:06:00.3
|
||||||
|
|
||||||
|
# [Link]
|
||||||
|
# Name=eno4"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "Die $iface_file wird angepasst:"
|
||||||
|
|
||||||
|
# Funktion zum Auskommentieren der gesamten Datei
|
||||||
|
comment_out_all() {
|
||||||
|
local file="$1"
|
||||||
|
echo "✔ Kommentiere die gesamte Datei aus..."
|
||||||
|
# Kommt alle Zeilen der Datei aus
|
||||||
|
sed -i 's/^[[:space:]]*/# /' "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Funktion zum Prüfen, ob ein nicht gewolltes Interface existiert
|
||||||
|
check_for_unwanted_interfaces() {
|
||||||
|
local file="$1"
|
||||||
|
local wanted_interfaces=("lo" "${interfaces[@]}")
|
||||||
|
local unwanted_found=0
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# Leerzeilen & Kommentare überspringen
|
||||||
|
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
|
||||||
|
|
||||||
|
# FIX 1: sauberes Token-Parsing statt Regex
|
||||||
|
read -r keyword iface proto rest <<<"$line"
|
||||||
|
|
||||||
|
[[ "$keyword" == "iface" ]] || continue
|
||||||
|
|
||||||
|
# Vergleich bleibt wie bei dir
|
||||||
|
if [[ ! " ${wanted_interfaces[@]} " =~ " $iface " ]]; then
|
||||||
|
echo "❌ Unerwünschtes Interface gefunden: $iface"
|
||||||
|
unwanted_found=1
|
||||||
|
fi
|
||||||
|
done < "$file"
|
||||||
|
|
||||||
|
return $unwanted_found
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Funktion zum Sicherstellen, dass ein Interface existiert
|
||||||
|
ensure_interface() {
|
||||||
|
local file="$1"
|
||||||
|
local iface="$2"
|
||||||
|
local proto="$3"
|
||||||
|
|
||||||
|
[[ -f "$file" ]] || touch "$file"
|
||||||
|
|
||||||
|
# Prüfen, ob iface-Zeile existiert
|
||||||
|
if grep -Eq "^[[:space:]]*iface[[:space:]]+$iface([[:space:]]|\$)" "$file"; then
|
||||||
|
echo "✔ iface $iface $proto bereits vorhanden"
|
||||||
|
else
|
||||||
|
echo "➕ iface $iface $proto fehlt – anhängen"
|
||||||
|
{
|
||||||
|
echo
|
||||||
|
echo "iface $iface $proto"
|
||||||
|
} >> "$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sicherstellen, dass vor der iface-Zeile ein Zeilenumbruch ist
|
||||||
|
sed -i "/iface[[:space:]]+$iface[[:space:]]+$proto/i \\ " "$file"
|
||||||
|
|
||||||
|
# Prüfen, ob auto <iface> existiert
|
||||||
|
if grep -Eq "^[[:space:]]*auto[[:space:]]+$iface([[:space:]]|\$)" "$file"; then
|
||||||
|
echo "✔ auto $iface vorhanden"
|
||||||
|
else
|
||||||
|
echo "↺ auto $iface fehlt – vor iface einfügen"
|
||||||
|
# auto direkt vor iface einfügen
|
||||||
|
sed -i "/^[[:space:]]*iface[[:space:]]\+$iface[[:space:]]\+$proto/i auto $iface" "$file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Füge die Quelle für interfaces.d hinzu
|
||||||
|
add_source() {
|
||||||
|
local file="$1"
|
||||||
|
if ! grep -Eq "^[[:space:]]*source[[:space:]]+/etc/network/interfaces.d/\*" "$file"; then
|
||||||
|
echo "➕ source /etc/network/interfaces.d/* fehlt – hinzufügen"
|
||||||
|
echo "source /etc/network/interfaces.d/*" >> "$file"
|
||||||
|
else
|
||||||
|
echo "✔ source /etc/network/interfaces.d/* vorhanden"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Füge immer das Loopback Interface hinzu
|
||||||
|
add_loopback_interface() {
|
||||||
|
local file="$1"
|
||||||
|
if ! grep -Eq "^[[:space:]]*iface[[:space:]]+lo[[:space:]]\+inet[[:space:]]+loopback" "$file"; then
|
||||||
|
echo "➕ iface lo inet loopback fehlt – hinzufügen"
|
||||||
|
{
|
||||||
|
echo "auto lo"
|
||||||
|
echo "iface lo inet loopback"
|
||||||
|
} >> "$file"
|
||||||
|
else
|
||||||
|
echo "✔ iface lo inet loopback vorhanden"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temporäres Deaktivieren von 'set -e'
|
||||||
|
set +e
|
||||||
|
|
||||||
|
# Prüfe auf nicht gewollte Interfaces und kommentiere die Datei aus, wenn notwendig
|
||||||
|
check_for_unwanted_interfaces "$iface_file"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
# Wenn ein unerwünschtes Interface gefunden wurde, kommentiere die gesamte Datei aus und füge loopback + interfaces.d zu
|
||||||
|
comment_out_all "$iface_file"
|
||||||
|
add_source "$iface_file"
|
||||||
|
add_loopback_interface "$iface_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wiederherstellen von 'set -e'
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Setze die Konfiguration für die benötigten Interfaces
|
||||||
|
for iface in "${interfaces[@]}"; do
|
||||||
|
ensure_interface "$iface_file" "$iface" "inet dhcp"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "🔄 Neustart von networking.service..."
|
||||||
|
systemctl restart networking.service
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "📋 Status networking.service:"
|
||||||
|
systemctl status networking.service --no-pager -l
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "🌐 networkctl list:"
|
||||||
|
networkctl list
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "🔍 Detailstatus der Interfaces:"
|
||||||
|
networkctl status "${interfaces[@]}" || true
|
||||||
235
bash/special/supermicro_x9dri-ln4f.sh
Normal file
235
bash/special/supermicro_x9dri-ln4f.sh
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ein kleines Skript dass:
|
||||||
|
# 1. Dateien erstellt, die den Namen der Network-Interfaces an ihren pci-path binden
|
||||||
|
# 2. Die /etc/network/interfaces auskommentiert falls dort unbekannte interfaces stehen
|
||||||
|
# 3. alle definierten Interfaces + loopback in die /etc/network/interfaces schreibt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Standardwert für Interfaces (wenn keine übergeben werden)
|
||||||
|
interfaces=()
|
||||||
|
iface_file="/etc/network/interfaces"
|
||||||
|
name_dir="/etc/systemd/network"
|
||||||
|
|
||||||
|
# Verarbeite die übergebenen Shortflags
|
||||||
|
while getopts "i:f:" opt; do
|
||||||
|
case $opt in
|
||||||
|
i)
|
||||||
|
interfaces+=("$OPTARG")
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
iface_file="$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 [-f interfaces-file] [-i interface] [-i interface2] ..."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Wenn keine Interfaces übergeben wurden, nutze Standard-Interfaces
|
||||||
|
if [ ${#interfaces[@]} -eq 0 ]; then
|
||||||
|
interfaces=("eno1" "eno2" "eno3" "eno4")
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "Die Links für die Interfacenamen werden erstellt:"
|
||||||
|
# Hier werden die Interface-Namen mit ihren Bussen gelinkt -> einheitlich, persistente Bennenung
|
||||||
|
create_link_file() {
|
||||||
|
local file="$name_dir/$1"
|
||||||
|
local content="$2"
|
||||||
|
|
||||||
|
if [[ -f "$file" ]]; then
|
||||||
|
if diff -q <(printf "%s\n" "$content") "$file" >/dev/null; then
|
||||||
|
echo "✔ $file existiert bereits und ist korrekt"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "↺ $file existiert, Inhalt unterscheidet sich – aktualisiere"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "➕ $file existiert nicht – erstelle"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "%s\n" "$content" > "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# # Erstelle Links für alle Interfaces
|
||||||
|
# for iface in "${interfaces[@]}"; do
|
||||||
|
# create_link_file "10-$iface.link" \
|
||||||
|
# "[Match]
|
||||||
|
# Path=pci-0000:06:00.1
|
||||||
|
|
||||||
|
# [Link]
|
||||||
|
# Name=$iface"
|
||||||
|
# done
|
||||||
|
|
||||||
|
create_link_file "10-eno2.link" \
|
||||||
|
"[Match]
|
||||||
|
Path=pci-0000:06:00.1
|
||||||
|
|
||||||
|
[Link]
|
||||||
|
Name=eno2"
|
||||||
|
|
||||||
|
create_link_file "10-eno3.link" \
|
||||||
|
"[Match]
|
||||||
|
Path=pci-0000:06:00.2
|
||||||
|
|
||||||
|
[Link]
|
||||||
|
Name=eno3"
|
||||||
|
|
||||||
|
create_link_file "10-eno4.link" \
|
||||||
|
"[Match]
|
||||||
|
Path=pci-0000:06:00.3
|
||||||
|
|
||||||
|
[Link]
|
||||||
|
Name=eno4"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "Die $iface_file wird angepasst:"
|
||||||
|
|
||||||
|
# Funktion zum Auskommentieren der gesamten Datei
|
||||||
|
comment_out_all() {
|
||||||
|
local file="$1"
|
||||||
|
echo "✔ Kommentiere die gesamte Datei aus..."
|
||||||
|
# Kommt alle Zeilen der Datei aus
|
||||||
|
sed -i 's/^[[:space:]]*/# /' "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Funktion zum Prüfen, ob ein nicht gewolltes Interface existiert
|
||||||
|
check_for_unwanted_interfaces() {
|
||||||
|
local file="$1"
|
||||||
|
local wanted_interfaces=("lo" "${interfaces[@]}")
|
||||||
|
local unwanted_found=0
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# Leerzeilen & Kommentare überspringen
|
||||||
|
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
|
||||||
|
|
||||||
|
# FIX 1: sauberes Token-Parsing statt Regex
|
||||||
|
read -r keyword iface proto rest <<<"$line"
|
||||||
|
|
||||||
|
[[ "$keyword" == "iface" ]] || continue
|
||||||
|
|
||||||
|
# Vergleich bleibt wie bei dir
|
||||||
|
if [[ ! " ${wanted_interfaces[@]} " =~ " $iface " ]]; then
|
||||||
|
echo "❌ Unerwünschtes Interface gefunden: $iface"
|
||||||
|
unwanted_found=1
|
||||||
|
fi
|
||||||
|
done < "$file"
|
||||||
|
|
||||||
|
return $unwanted_found
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Funktion zum Sicherstellen, dass ein Interface existiert
|
||||||
|
ensure_interface() {
|
||||||
|
local file="$1"
|
||||||
|
local iface="$2"
|
||||||
|
local proto="$3"
|
||||||
|
|
||||||
|
[[ -f "$file" ]] || touch "$file"
|
||||||
|
|
||||||
|
# Prüfen, ob iface-Zeile existiert
|
||||||
|
if grep -Eq "^[[:space:]]*iface[[:space:]]+$iface([[:space:]]|\$)" "$file"; then
|
||||||
|
echo "✔ iface $iface $proto bereits vorhanden"
|
||||||
|
else
|
||||||
|
echo "➕ iface $iface $proto fehlt – anhängen"
|
||||||
|
{
|
||||||
|
echo
|
||||||
|
echo "iface $iface $proto"
|
||||||
|
} >> "$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sicherstellen, dass vor der iface-Zeile ein Zeilenumbruch ist
|
||||||
|
sed -i "/iface[[:space:]]+$iface[[:space:]]+$proto/i \\ " "$file"
|
||||||
|
|
||||||
|
# Prüfen, ob auto <iface> existiert
|
||||||
|
if grep -Eq "^[[:space:]]*auto[[:space:]]+$iface([[:space:]]|\$)" "$file"; then
|
||||||
|
echo "✔ auto $iface vorhanden"
|
||||||
|
else
|
||||||
|
echo "↺ auto $iface fehlt – vor iface einfügen"
|
||||||
|
# auto direkt vor iface einfügen
|
||||||
|
sed -i "/^[[:space:]]*iface[[:space:]]\+$iface[[:space:]]\+$proto/i auto $iface" "$file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Füge die Quelle für interfaces.d hinzu
|
||||||
|
add_source() {
|
||||||
|
local file="$1"
|
||||||
|
if ! grep -Eq "^[[:space:]]*source[[:space:]]+/etc/network/interfaces.d/\*" "$file"; then
|
||||||
|
echo "➕ source /etc/network/interfaces.d/* fehlt – hinzufügen"
|
||||||
|
echo "source /etc/network/interfaces.d/*" >> "$file"
|
||||||
|
else
|
||||||
|
echo "✔ source /etc/network/interfaces.d/* vorhanden"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Füge immer das Loopback Interface hinzu
|
||||||
|
add_loopback_interface() {
|
||||||
|
local file="$1"
|
||||||
|
if ! grep -Eq "^[[:space:]]*iface[[:space:]]+lo[[:space:]]\+inet[[:space:]]+loopback" "$file"; then
|
||||||
|
echo "➕ iface lo inet loopback fehlt – hinzufügen"
|
||||||
|
{
|
||||||
|
echo "auto lo"
|
||||||
|
echo "iface lo inet loopback"
|
||||||
|
} >> "$file"
|
||||||
|
else
|
||||||
|
echo "✔ iface lo inet loopback vorhanden"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temporäres Deaktivieren von 'set -e'
|
||||||
|
set +e
|
||||||
|
|
||||||
|
# Prüfe auf nicht gewollte Interfaces und kommentiere die Datei aus, wenn notwendig
|
||||||
|
check_for_unwanted_interfaces "$iface_file"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
# Wenn ein unerwünschtes Interface gefunden wurde, kommentiere die gesamte Datei aus und füge loopback + interfaces.d zu
|
||||||
|
comment_out_all "$iface_file"
|
||||||
|
add_source "$iface_file"
|
||||||
|
add_loopback_interface "$iface_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wiederherstellen von 'set -e'
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Setze die Konfiguration für die benötigten Interfaces
|
||||||
|
for iface in "${interfaces[@]}"; do
|
||||||
|
ensure_interface "$iface_file" "$iface" "inet dhcp"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "🔄 Neustart von networking.service..."
|
||||||
|
systemctl restart networking.service
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "📋 Status networking.service:"
|
||||||
|
systemctl status networking.service --no-pager -l
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "🌐 networkctl list:"
|
||||||
|
networkctl list
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "🔍 Detailstatus der Interfaces:"
|
||||||
|
networkctl status "${interfaces[@]}" || true
|
||||||
14
ps/generic/csv_collum_join.ps
Normal file
14
ps/generic/csv_collum_join.ps
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# CSV-Datei einlesen
|
||||||
|
$data = Import-Csv -Path "C:\Users\joekun\Downloads\report.csv" -Delimiter ";"
|
||||||
|
|
||||||
|
# Spaltennamen abrufen
|
||||||
|
$spaltennamen = $data[0].PSObject.Properties.Name
|
||||||
|
|
||||||
|
# Die zweite Spalte ermitteln
|
||||||
|
$zweiteSpalte = $spaltennamen[1]
|
||||||
|
|
||||||
|
# Alle Werte aus der zweiten Spalte zusammenfassen
|
||||||
|
$zusammenfassung = ($data | ForEach-Object { $_.$zweiteSpalte }) -join " + "
|
||||||
|
|
||||||
|
# Zusammenfassung ausgeben oder weiterverarbeiten
|
||||||
|
$zusammenfassung | Out-File C:\Users\joekun\Downloads\zusammengefasst.txt
|
||||||
30
ps/generic/scan_host_network.ps
Normal file
30
ps/generic/scan_host_network.ps
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Lokales Subnetz automatisch ermitteln
|
||||||
|
$localIP = (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias Ethernet* | Where-Object {$_.PrefixLength -le 32}).IPAddress
|
||||||
|
if (-not $localIP) { $localIP = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.PrefixLength -le 32}).IPAddress }
|
||||||
|
$subnet = ($localIP -split '\.')[0..2] -join '.'
|
||||||
|
|
||||||
|
Write-Host "Scanning subnet $subnet.0/24 ..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$results = @()
|
||||||
|
|
||||||
|
1..254 | ForEach-Object {
|
||||||
|
$ip = "$subnet.$_"
|
||||||
|
if (Test-Connection -ComputerName $ip -Count 1 -Quiet) {
|
||||||
|
# MAC-Adresse über ARP abfragen
|
||||||
|
$mac = (arp -a $ip | Select-String $ip) -replace '\s{2,}', ' ' | ForEach-Object { ($_ -split ' ')[1] }
|
||||||
|
# Hostname auflösen
|
||||||
|
try {
|
||||||
|
$hostname = ([System.Net.Dns]::GetHostEntry($ip)).HostName
|
||||||
|
} catch {
|
||||||
|
$hostname = "unbekannt"
|
||||||
|
}
|
||||||
|
$results += [PSCustomObject]@{
|
||||||
|
IP = $ip
|
||||||
|
MAC = $mac
|
||||||
|
Hostname = $hostname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ergebnisse ausgeben
|
||||||
|
$results | Format-Table -AutoSize
|
||||||
60
ps/generic/uninstall_install_history.ps
Normal file
60
ps/generic/uninstall_install_history.ps
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# --------------------------------------------
|
||||||
|
# SOFTWARE INSTALL / UNINSTALL HISTORY
|
||||||
|
# --------------------------------------------
|
||||||
|
|
||||||
|
Write-Host "`n=== SOFTWARE INSTALLATIONEN (Registry + Store) ===`n" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
# --- Installationen über Registry ---
|
||||||
|
$regPaths = @(
|
||||||
|
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
|
||||||
|
"HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*",
|
||||||
|
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||||
|
)
|
||||||
|
|
||||||
|
$installs = foreach ($path in $regPaths) {
|
||||||
|
Get-ItemProperty $path -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.DisplayName -and $_.InstallDate } |
|
||||||
|
Select-Object @{
|
||||||
|
Name="Date"; Expression={
|
||||||
|
try {
|
||||||
|
[datetime]::ParseExact($_.InstallDate, "yyyyMMdd", $null)
|
||||||
|
} catch {
|
||||||
|
$null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, DisplayName, DisplayVersion, Publisher, UninstallString
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Installationen über Windows Store (AppX) ---
|
||||||
|
$appx = Get-AppxPackage |
|
||||||
|
Select-Object @{
|
||||||
|
Name = "Date";
|
||||||
|
Expression = { $_.InstallDate }
|
||||||
|
}, Name, Version, Publisher
|
||||||
|
|
||||||
|
$allInstalls = $installs + $appx | Sort-Object Date
|
||||||
|
|
||||||
|
$allInstalls | Format-Table Date, DisplayName, DisplayVersion, Publisher -AutoSize
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------
|
||||||
|
Write-Host "`n=== SOFTWARE DEINSTALLATIONEN (Event Viewer) ===`n" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
# MsiInstaller Events:
|
||||||
|
# 1034 = Uninstall
|
||||||
|
# 11724 = Removal success
|
||||||
|
# 11707 = Install success (info only)
|
||||||
|
|
||||||
|
$events = Get-WinEvent -FilterHashtable @{
|
||||||
|
LogName = "Application"
|
||||||
|
ProviderName = "MsiInstaller"
|
||||||
|
} -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object {
|
||||||
|
$_.Id -eq 1034 -or $_.Id -eq 11724
|
||||||
|
} |
|
||||||
|
Select-Object TimeCreated, Id, Message
|
||||||
|
|
||||||
|
$events | Sort-Object TimeCreated |
|
||||||
|
Format-Table TimeCreated, Id, Message -Wrap -AutoSize
|
||||||
|
|
||||||
|
Write-Host "`nFertig!`n"
|
||||||
Loading…
Reference in New Issue
Block a user