Discussion:
Changing local admin password on domain computers
(too old to reply)
unknown
2010-03-02 15:17:24 UTC
Permalink
I have written the below powershell script to change the local administrator
account on some servers that I have listed in the servers.txt file.

$name="administrator"
get-content c:\servers.txt | foreach-object {
[adsi]$admin="WinNT://$_/$name,user"
$admin.SetPassword("password2")
$admin.setinfo()
}

When I run the script i get the following error :

Exception retrieving member "setpassword". The network path was not found
$admin.setpassword <<<< ("password2")
categoryinfo : Notspecified: (:) [], ExtendedTypeSystemException.

Any ideas why the above script fails. If I use the setpassword for changing
administrator password on one server it works fine. The servers.txt file is
setup in notepad.

My eventual aim is to be able to reset the local admin passwords of all my
domain computers or a selective domain computers. Is the above way best way
to do this. Is there a way I can get a list of all my domain computers in a
txt file and then apply to the script above. Any advice thanks.
Chris Dent
2010-03-02 19:44:12 UTC
Permalink
Hey,

It doesn't like whatever value you passed for the computer name ($_)
when it threw the error. You might Write-Host $_ as it's running to
verify which system it's connecting to.

Incidentally, you don't need SetInfo in there for the SetPassword method
call. Only when you're setting properties on the account.

For the AD part, most assuredly. If you're not averse to downloading
things the Quest AD CmdLets would help a great deal. For instance, you
might want to do this task for every member workstation, and if you do...


Get-QADComputer -ComputerRole Member -OSName "Windows XP*" | %{
([ADSI]"WinNT://$($_.Name)/Administrator").SetPassword("NewPassword")
}


You can still export to a text file if you prefer. It's just sometimes
nicer to cut out the middle man.

HTH

Chris
Post by unknown
I have written the below powershell script to change the local administrator
account on some servers that I have listed in the servers.txt file.
$name="administrator"
get-content c:\servers.txt | foreach-object {
[adsi]$admin="WinNT://$_/$name,user"
$admin.SetPassword("password2")
$admin.setinfo()
}
Exception retrieving member "setpassword". The network path was not found
$admin.setpassword <<<< ("password2")
categoryinfo : Notspecified: (:) [], ExtendedTypeSystemException.
Any ideas why the above script fails. If I use the setpassword for changing
administrator password on one server it works fine. The servers.txt file is
setup in notepad.
My eventual aim is to be able to reset the local admin passwords of all my
domain computers or a selective domain computers. Is the above way best way
to do this. Is there a way I can get a list of all my domain computers in a
txt file and then apply to the script above. Any advice thanks.
Continue reading on narkive:
Loading...