Initialer Import der Synology Scripts
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
$clients = @("192.168.1.249")
|
||||
|
||||
foreach ($client in $clients) {
|
||||
$sshSession = New-SSHSession -ComputerName $client -Credential $cred
|
||||
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo useradd -m -s /bin/bash username"
|
||||
}
|
||||
$groupName = "neue_gruppe"
|
||||
|
||||
foreach ($client in $clients) {
|
||||
$sshSession = New-SSHSession -ComputerName $client -Credential $cred
|
||||
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo groupadd $groupName"
|
||||
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "sudo usermod -aG $groupName username"
|
||||
}
|
||||
$password = "Passwort123!"
|
||||
|
||||
foreach ($client in $clients) {
|
||||
$sshSession = New-SSHSession -ComputerName $client -Credential $cred
|
||||
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "username", $securePassword
|
||||
Invoke-SSHCommand -SessionId $sshSession.SessionId -Command "echo 'username:$password' | sudo chpasswd"
|
||||
}
|
||||
Reference in New Issue
Block a user