我试图在Windows 2008服务器上自动设置一组本地用户帐户的密码。我尝试过一些东西,如果我不使用像这样的用户名变量,这就可以了:
$user = [adsi]"WinNT://$computer/SomeUserName"我的剧本块在下面。知道我做错什么了吗?
$accounts = Get-Content c:\userlist.txt
$computer = SomeComputerName
$password = "MyPassword"
Foreach($account in $accounts)
{
$user = [adsi]"WinNT://$computer/$account"
$user.SetPassword("$Password")
$user.SetInfo()
}当我为用户使用$account变量(从文本文件列表中)时,我遇到的错误是:
The following exception occurred while retrieving member "SetInfo": "The group name could not be found.谢谢你的帮助..。
发布于 2015-07-21 21:24:01
您的机器似乎试图将$account值解析为本地组名。
可以指定它是您想要的用户对象,方法是在帐户名后面加上逗号和字符串user。
$user = [adsi]"WinNT://$computer/$account,user"https://stackoverflow.com/questions/31549493
复制相似问题