Initialer Import der Synology Scripts

This commit is contained in:
root
2026-08-05 08:43:57 +02:00
commit 5e32a7c411
404 changed files with 79932 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
# Benutzername, Gruppe und Passwort eingeben
$username = Read-Host "Geben Sie den Benutzernamen ein"
$group = Read-Host "Geben Sie den Gruppennamen ein"
$password = Read-Host "Geben Sie das Passwort ein" -AsSecureString
# Konvertiere Passwort in Klartext
$passwordPlainText = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
# Liste der Clients
#$clients = @("client1", "client2", "client3", "client4", "client5", "client6", "client7", "client8", "client9", "client10")
$clietns = @("192.168.1.249.")
foreach ($client in $clients) {
# SSH-Verbindung herstellen
$sshSession = New-SSHSession -ComputerName $client -Credential $cred
# Benutzer erstellen
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo useradd -m -s /bin/bash $username"
# Gruppe erstellen und Benutzer hinzufügen
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo groupadd $group"
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo usermod -aG $group $username"
# Passwort setzen
$plaintext = [System.Text.Encoding]::UTF8.GetBytes("$username:$passwordPlainText")
$base64 = [Convert]::ToBase64String($plaintext)
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "echo $base64 | base64 -d | sudo chpasswd"
}