Contact Info

Crumbtrail

ActiveXperts.com » Administration » Scripts » WMI » jscript sample

Win32_Binary jscript sample code

The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The Win32_Binary WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Description

The Win32_Binary WMI class represents binary information (such as bitmaps, icons, executable files, and so on) that are used by an installation.

Sample Code

use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my @computers = ("DELL17");
foreach my $computer (@computers) {
   print "\n";
   print "==========================================\n";
   print "Computer: $computer\n";
   print "==========================================\n";

   my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
   my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_BIOS", "WQL",
                  wbemFlagReturnImmediately | wbemFlagForwardOnly);

   foreach my $objItem (in $colItems) {
      print "BiosCharacteristics: " . join(",", (in $objItem->{BiosCharacteristics})) . "\n";
      print "BIOSVersion: " . join(",", (in $objItem->{BIOSVersion})) . "\n";
      print "BuildNumber: $objItem->{BuildNumber}\n";
      print "Caption: $objItem->{Caption}\n";
      print "CodeSet: $objItem->{CodeSet}\n";
      print "CurrentLanguage: $objItem->{CurrentLanguage}\n";
      print "Description: $objItem->{Description}\n";
      print "IdentificationCode: $objItem->{IdentificationCode}\n";
      print "InstallableLanguages: $objItem->{InstallableLanguages}\n";
      print "InstallDate: $objItem->{InstallDate}\n";
      print "LanguageEdition: $objItem->{LanguageEdition}\n";
      print "ListOfLanguages: " . join(",", (in $objItem->{ListOfLanguages})) . "\n";
      print "Manufacturer: $objItem->{Manufacturer}\n";
      print "Name: $objItem->{Name}\n";
      print "OtherTargetOS: $objItem->{OtherTargetOS}\n";
      print "PrimaryBIOS: $objItem->{PrimaryBIOS}\n";
      print "ReleaseDate: $objItem->{ReleaseDate}\n";
      print "SerialNumber: $objItem->{SerialNumber}\n";
      print "SMBIOSBIOSVersion: $objItem->{SMBIOSBIOSVersion}\n";
      print "SMBIOSMajorVersion: $objItem->{SMBIOSMajorVersion}\n";
      print "SMBIOSMinorVersion: $objItem->{SMBIOSMinorVersion}\n";
      print "SMBIOSPresent: $objItem->{SMBIOSPresent}\n";
      print "SoftwareElementID: $objItem->{SoftwareElementID}\n";
      print "SoftwareElementState: $objItem->{SoftwareElementState}\n";
      print "Status: $objItem->{Status}\n";
      print "TargetOperatingSystem: $objItem->{TargetOperatingSystem}\n";
      print "Version: $objItem->{Version}\n";
      print "\n";
   }
}sub WMIDateStringToDate(strDate)
{
   return "blah";
}