2017-01-30 62 views
0

我想創建一個用戶並將其添加到標準用戶組。將用戶添加到默認用戶組

我該怎麼做?

代碼:

$button_BenutzerErstellen_OnClick = { 
    $textBox6.Text 
    # Define password variable as SecureString 
    $password = ConvertTo-SecureString $textBox7.Text -AsPlainText -Force 

    # Check for empty Textboxes 
    if (($handler_textBox6.Text -eq 0) -or ($handler_textBox7.TextLength -eq 0)) { 
     [System.Windows.Forms.MessageBox]::Show("Bitte füllen Sie alle Kriterien aus.", "Combat 19") 
    } else { 
     # create user 
     New-LocalUser $textBox6.Text -Password $password -Description $textBox1 
     [System.Windows.Forms.MessageBox]::Show("Benutzer wurde erstellt!", "Combat 19") 
    } 
} 
+0

馬克嗨,你嘗試過什麼,當談到創建用戶? –

+0

我可以創建一個用戶,但我創建後無法登錄。所以用戶需要在默認的用戶組中。我想要移動組中的新用戶。 –

+0

通常會有一些複製時間,從創建用戶到可以以他們身份登錄時,可能需要15分鐘才能再次同步 –

回答

0

我不知道怎麼的用戶創建與您選定的腳本鏈接。 我相信你在談論本地用戶和組織。

然後你可以使用:

爲用戶

NET USER username "password" /ADD 

將其添加到組

NET LOCALGROUP "group" "user" /add 
+0

感謝它現在的作品! –

+0

@MarcHofstetter:接受答案,如果它可以幫助你 –