1
我試圖在Windows 2008服務器上自動設置一堆本地用戶帳戶的密碼。我已經嘗試了一些東西,這個工程如果我不使用變量這樣的用戶名:使用Powershell和ADSI設置本地密碼
$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()
}
我得到當我使用$帳戶變量的用戶(從文本文件列表)的錯誤是:
The following exception occurred while retrieving member "SetInfo": "The group name could not be found.
感謝您的幫助......
謝謝你 - 這做到了! –