Powershell添加本地用户
我想创建一个Powershell Gui脚本,可以创建本地用户。这里的问题是,为什么代码需要一个参数?用-nopassword它就行了 代码:Powershell添加本地用户,powershell,Powershell,我想创建一个Powershell Gui脚本,可以创建本地用户。这里的问题是,为什么代码需要一个参数?用-nopassword它就行了 代码: $button_BenutzerErstellen_OnClick= { $textBox6.Text $textBox7 = ConvertTo-SecureString -AsPlainText -Force if (($handler_textBox6.Text -eq 0) -or
$button_BenutzerErstellen_OnClick=
{
$textBox6.Text
$textBox7 = ConvertTo-SecureString -AsPlainText -Force
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{
New-LocalUser $textBox6.Text -Password $textBox7 -Description $textBox1.Text
}
使用
TextBox
es上的Text
属性:
New-LocalUser $textBox6.Text -Password $textBox7 -Description $textBox1.Text
您正在尝试为New LocalUser cmdlet的Password属性指定字符串值,该属性不是有效的预期数据类型。 删除此项:
$textBox7 = ConvertTo-SecureString -AsPlainText -Force
并将else语句更改为:
New-LocalUser $textBox6.Text -Password $($textBox7.Text | ConvertTo-SecureString -AsPlainText -Force) -Description $textBox1.Text
您还可以将网络用户作为一个在线用户使用
NET USER username "password" /ADD
谢谢,但是为什么代码要我输入字符串-没有密码的工作,但它的密码要求我的字符串。