wmi - Using Powershell and ADSI to set local passwords -
i'm trying automate setting bunch of local user accounts' password on windows 2008 server. i've tried few things , works if don't use variable username this:
$user = [adsi]"winnt://$computer/someusername"
my script block below... ideas i'm doing wrong?
$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 error when use $account variable user (from text file list) is:
the following exception occurred while retrieving member "setinfo": "the group name not found.
thanks help...
it seems machine tries resolve $account
value local group name.
you can specify user object want, following account name comma , string user
:
$user = [adsi]"winnt://$computer/$account,user"
Comments
Post a Comment