unknown
2010-03-02 15:17:24 UTC
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.
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.