I wrote a similar script a while back to collect SUS data. I leave the CSV
logging code up to you.
################################################################
use Win32::TieRegistry( Delimiter=>"\\", ArrayValues=>0 );
$shellstr="net view";
@machs=`"$shellstr"`; # A recent MS patch seems to require "s inside the
` marks in some cases now. I don't know why.
foreach $_ (@machs)
{
($mach,$dum)=split(/\s/);
if (-e "$mach\\c\$\\ntldr") # an assumption based on where NTLDR is
located in my environment. YMMV.
{
$regstr="$mach\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\
WindowsUpdate\\";
$killx=$Registry->{$regstr};
if (exists($killx->{"AU\\"})) # testing for a key from one key up
improves safety
{
print "$mach: ";
$regstr="$mach\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\
WindowsUpdate\\AU\\";
$killx=$Registry->{$regstr};
if (exists($killx->{"\\AUOptions"})) # to test for a value, put \\ in
front of the value name instead of behind it
{
$val=hex($killx->GetValue('AUOptions')); # AUOptions type = REG_DWORD
print " AUOptions: $val\t";
}
else {print "AUOPtions not found!\t";}
if (exists($killx->{"\\UseWUServer"}))
{
$val=hex($killx->GetValue('UseWUServer')); # UseWUServer is a
REG_DWORD, too.
print " UseWUServer: $val\n";
}
else {print " UseWUServer not found!\n";}
}
else
{print "AU key not found on $mach!\n";}
}
else {print "Unable to connect to registry on $mach!\n";}
}
################################################################
-----Original Message-----
From: Bateman, John (IQAUS is) [mailto:[EMAIL PROTECTED]
Sent: Friday, September 19, 2003 3:33 PM
To: '[EMAIL PROTECTED]'
Subject: Connecting to remote registry
Good Afternoon,
I am trying to use perl to connect to each machine in my domain, read
the value of a registry key, output that to a csv, and move on to the next
machine. For the most part it is successful in doing this. However, I
can't seem to connect consistently to the machines. I will get a error
"Could not connect to machine" from my else statement. I can connect to the
machine manually and the registry key is there. I have tried many different
versions of code and I always seem to encounter this problem. I have
enclosed some code that works "most the time". I know there are also other
reasons that could be causing this to occur (outside of perl) but is there a
better way to connect to machines?
Thank You
john
[Bobbitt]
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs