|
Hello all! Sorry to bother you all with something I am sure you will
all find pretty simple, but I cannot get this to work. This script is pulling the servers from
a text file. I have tried many
variations, but cannot get my password to change, OR my account to rename. Any help would be wonderful! Code== use
Win32::AdminMisc; use
Win32::NetAdmin; print "What
is the name of the file that has the lists the computers:\n"; $Ffilename = <STDIN>; chomp($Ffilename); $output = "c:\\LocalAdmin Result.txt"; open
(COMPUTERLIST,"< $Ffilename"); while
(<COMPUTERLIST>) {
my $server = $_;
chomp($server);
my $oldacct =
"Administrator";
my $password = "password";
my $newacct = "LocalAdmin";
open(OUTFILE, ">>$output") || die
"Cannot open output file $output";
if (Win32::NetAdmin::UsersExist($server, $newacct))
{
&passchg;
}
elsif (Win32::NetAdmin::UsersExist($server,
$oldacct))
{
&rename;
&passchg;
}
else
{
printf OUTFILE
"Nothings working!!!!!\n";
}
} close(OUTFILE); sub passchg { my $psresult =
Win32::AdminMisc::SetPassword($server, "LocalAdmin",
"password"); if ($psresult == "1") { printf OUTFILE "\n$server - LocalAdmin found and
password changed\n"; } else { printf OUTFILE "\n$server - LocalAdmin found but
PASSWORD CHANGE FAILED\n"; } } sub rename { my $nmresult =
Win32::AdminMisc::RenameUser($server, $oldacct, $newacct); if ($nmresult == "1") { printf OUTFILE "\n$server - RENAMED to LocalAdmin"; } else { printf OUTFILE "\n$server - RENAME FAILED!\n"; } } End== Matthew Allen x46645 Systems Administrator Enterprise Systems
Management |
