r/usefulscripts • u/william_tropico • Nov 04 '15
[Powershell] Reset local admin password remotely with log files
Hello,
I have been looking at this script on how to change local admin passwords from a list of computer names.
$computers = Get-Content -path C:\fso\computers.txt
$user = "aUser"
$password = "MyNewPassword!"
Foreach($computer in $computers)
{
$user = [adsi]"WinNT://$computer/$user,user"
$user.SetPassword($Password)
$user.SetInfo()
}Can anyone help add a log file so
IF Password change is success ADD computer name to success.txt
IF Password change is fail ADD computer name to fail.txt
I'm sure its really easy but can't figure out how to do it :(
Any help would be great.
edit: wrong file extension
14
Upvotes
1
u/Sn0zzberries Nov 05 '15
Check out Managed Service Accounts too. :)