Recently in windows Category

Win32::WindowsUpdate 0.4 (updated)

By Dusty on February 19, 2009 3:40 AM · No Comments
http://search.cpan.org/~WILSOND/Win32-WindowsUpdate/lib/Win32/WindowsUpdate.pm

Updated again.  Added the ability to not auto reboot after patching (that's so annoying!) as well as set the auto update settings (disable, notify, download, automatic).  It's been uploaded to the CPAN and should appear soon.

Windows Updates in Perl

By Dusty on February 17, 2009 4:36 PM · No Comments

Need to get Windows Updates via Perl?  Here's the way I did it:

use Win32::OLE qw(in);
use Data::Dumper;

my $updateOLE = Win32::OLE->new('Microsoft.Update.Session') or die "ERROR creating Microsoft.Update.Session\n";
my $updateSearcher = $updateOLE->CreateUpdateSearcher or die "ERROR creating CreateUpdateSearcher\n";
$updateSearcher->SetProperty('Online', 1); # set to 1 to check online for updates, 0 to not check online. seems to default to online.
my $queryResult = $updateSearcher->Search("IsInstalled = 0 and IsHidden = 0");
my $updates = $queryResult->Updates;

my @updates;
foreach my $update (in $updates)
{
  my $info = {};

  $info->{UpdateId} = $update->Identity->UpdateID;
  $info->{Title} = $update->Title;
  $info->{Description} = $update->Description;
  $info->{RebootRequired} = $update->RebootRequired;
  $info->{ReleaseNotes} = $update->ReleaseNotes;
  $info->{EulaText} = $update->EulaText;
  $info->{EulaAccepted} = $update->EulaAccepted;

  push(@{$info->{Category}}, {Name => $_->Name, CategoryID=> $_->CategoryID}) foreach (in $update->Categories);
  push(@{$info->{MoreInfoUrl}}, $_) foreach (in $update->MoreInfoUrls);
  push(@{$info->{KBArticleID}}, $_) foreach (in $update->KBArticleIDs);
  push(@{$info->{SecurityBulletinID}}, $_) foreach (in $update->SecurityBulletinIDs);
  push(@{$info->{SupersededUpdateID}}, $_) foreach (in $update->SupersededUpdateIDs);

  push(@updates, $info);
}

print Dumper(\@updates)