pss
This commit is contained in:
parent
f15dcf632e
commit
5cba8fc035
34
Playbooks/update-pve.ps1
Normal file
34
Playbooks/update-pve.ps1
Normal file
@ -0,0 +1,34 @@
|
||||
# PowerShell-Skript zum Remote-Update auf Proxmox-Servern via SSH
|
||||
|
||||
# Server und SSH-Login-Daten
|
||||
$servers = @(
|
||||
@{ Host = "192.168.178.2"; User = "root"; Password = "2002Lahann1902Joaquin*+1902*" },
|
||||
@{ Host = "192.168.178.3"; User = "root"; Password = "2002Lahann1902Joaquin*+1902*" }
|
||||
)
|
||||
|
||||
# SSH-Session starten und Befehle ausführen
|
||||
foreach ($server in $servers) {
|
||||
Write-Host "Verbinde zu Server $($server.Host) ..."
|
||||
|
||||
# SSH-Verbindung aufbauen
|
||||
$session = New-SSHSession -ComputerName $server.Host -Credential (New-Object System.Management.Automation.PSCredential($server.User, (ConvertTo-SecureString $server.Password -AsPlainText -Force)))
|
||||
|
||||
if ($session) {
|
||||
Write-Host "Erfolgreich verbunden mit $($server.Host). Starte das Update und Upgrade..."
|
||||
|
||||
# Update der Paketliste und Upgrade
|
||||
$updateCommand = "apt update && apt upgrade -y && apt dist-upgrade -y && apt autoremove -y && apt autoclean -y"
|
||||
$result = Invoke-SSHCommand -SessionId $session.SessionId -Command $updateCommand
|
||||
|
||||
# Ausgabe der Ergebnisse
|
||||
Write-Host "Befehl ausgeführt auf $($server.Host):"
|
||||
Write-Host $result.Output
|
||||
|
||||
# Schließen der SSH-Verbindung
|
||||
Remove-SSHSession -SessionId $session.SessionId
|
||||
} else {
|
||||
Write-Host "Verbindung zu $($server.Host) fehlgeschlagen."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Update, Upgrade und Bereinigung auf allen Servern abgeschlossen."
|
||||
Loading…
Reference in New Issue
Block a user