Powershell New-ADUser到AD的问题

时间:2019-04-15 00:03:24

标签: powershell

我正在研究Windows服务器,并且是Powershell脚本的新手。我正在尝试通过电源外壳添加AD用户,但出现错误。 这是我的剧本

new-aduser
-name "Elizabeth Andersen"
-SameAccount "eander"
-GivenName "Elizabeth"
-Surname "Anderson"
-Path 'OU=Research,DC=adatum,dc=local'
-Enable $true
-AccountPassword "Pa$$w0rd"
-ChangePasswordAtLogon $true

此脚本有什么问题吗? 谢谢您的帮助

1 个答案:

答案 0 :(得分:0)

我建议阅读此cmdlet的文档。 You can find it here

未使用简单的字符串设置帐户密码,它需要SecureString。我会熟悉安全字符串,因为它们在PowerShell中经常出现。您可以使用ConvertTo-SecureString生成它们。

我还将仔细检查您的所有参数名称,因为我发现Enable不正确-应该为Enabled