Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Need help with script to change local administrator password

$
0
0

Hi I am trying to create/run a script to change the local administrator password on a list of servers off of a text file. I have had no success and I thought this would be pretty easy. Below is the script I foraged from different users trying to do the same thing. Please excuse me I am still learning PS so this might be an easy answer or just a stupid mistake on my part. Thanks for any help or advise it is much appreciated!

$computers=Get-Content-PathC:\Temp\serverlist.txt


$user

="administrator"


$Password

=Get-Content-PathC:\Temp\password.txt


Start-Transcript

c:\temp\pwlogging.txt


$PasswordCount

=0


Foreach

($computerin$computers) {


$newpass

=[adsi]"WinNT://$computer/$user"


$newpass

.SetPassword($Password[$PasswordCount])


$newpass

.SetInfo()


$PasswordCount

++


echo

"Setting password for$computer$userto$($Password[$PasswordCount])"


}


Stop-Transcript


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>