# 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" }