Win32_OperatingSystem perl 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_OperatingSystem WMI class can be used in ActiveXperts Network Monitor to monitor your servers.
Description
The Win32_OperatingSystem WMI class represents an operating system installed on a Win32 computer system. Any operating system that can be installed on a Win32 system is a descendent (or member) of this class. If the computer has multiple operating systems installed, this class returns only an instance for the currently active operating system.
Sample Code
use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my @computers = ("\localhost"); 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_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colItems) { print "BootDevice: $objItem->{BootDevice}\n"; print "BuildNumber: $objItem->{BuildNumber}\n"; print "BuildType: $objItem->{BuildType}\n"; print "Caption: $objItem->{Caption}\n"; print "CodeSet: $objItem->{CodeSet}\n"; print "CountryCode: $objItem->{CountryCode}\n"; print "CreationClassName: $objItem->{CreationClassName}\n"; print "CSCreationClassName: $objItem->{CSCreationClassName}\n"; print "CSDVersion: $objItem->{CSDVersion}\n"; print "CSName: $objItem->{CSName}\n"; print "CurrentTimeZone: $objItem->{CurrentTimeZone}\n"; print "DataExecutionPrevention_32BitApplications: $objItem->{DataExecutionPrevention_32BitApplications}\n"; print "DataExecutionPrevention_Available: $objItem->{DataExecutionPrevention_Available}\n"; print "DataExecutionPrevention_Drivers: $objItem->{DataExecutionPrevention_Drivers}\n"; print "DataExecutionPrevention_SupportPolicy: $objItem->{DataExecutionPrevention_SupportPolicy}\n"; print "Debug: $objItem->{Debug}\n"; print "Description: $objItem->{Description}\n"; print "Distributed: $objItem->{Distributed}\n"; print "EncryptionLevel: $objItem->{EncryptionLevel}\n"; print "ForegroundApplicationBoost: $objItem->{ForegroundApplicationBoost}\n"; print "FreePhysicalMemory: $objItem->{FreePhysicalMemory}\n"; print "FreeSpaceInPagingFiles: $objItem->{FreeSpaceInPagingFiles}\n"; print "FreeVirtualMemory: $objItem->{FreeVirtualMemory}\n"; print "InstallDate: $objItem->{InstallDate}\n"; print "LargeSystemCache: $objItem->{LargeSystemCache}\n"; print "LastBootUpTime: $objItem->{LastBootUpTime}\n"; print "LocalDateTime: $objItem->{LocalDateTime}\n"; print "Locale: $objItem->{Locale}\n"; print "Manufacturer: $objItem->{Manufacturer}\n"; print "MaxNumberOfProcesses: $objItem->{MaxNumberOfProcesses}\n"; print "MaxProcessMemorySize: $objItem->{MaxProcessMemorySize}\n"; print "Name: $objItem->{Name}\n"; print "NumberOfLicensedUsers: $objItem->{NumberOfLicensedUsers}\n"; print "NumberOfProcesses: $objItem->{NumberOfProcesses}\n"; print "NumberOfUsers: $objItem->{NumberOfUsers}\n"; print "Organization: $objItem->{Organization}\n"; print "OSLanguage: $objItem->{OSLanguage}\n"; print "OSProductSuite: $objItem->{OSProductSuite}\n"; print "OSType: $objItem->{OSType}\n"; print "OtherTypeDescription: $objItem->{OtherTypeDescription}\n"; print "PAEEnabled: $objItem->{PAEEnabled}\n"; print "PlusProductID: $objItem->{PlusProductID}\n"; print "PlusVersionNumber: $objItem->{PlusVersionNumber}\n"; print "Primary: $objItem->{Primary}\n"; print "ProductType: $objItem->{ProductType}\n"; print "QuantumLength: $objItem->{QuantumLength}\n"; print "QuantumType: $objItem->{QuantumType}\n"; print "RegisteredUser: $objItem->{RegisteredUser}\n"; print "SerialNumber: $objItem->{SerialNumber}\n"; print "ServicePackMajorVersion: $objItem->{ServicePackMajorVersion}\n"; print "ServicePackMinorVersion: $objItem->{ServicePackMinorVersion}\n"; print "SizeStoredInPagingFiles: $objItem->{SizeStoredInPagingFiles}\n"; print "Status: $objItem->{Status}\n"; print "SuiteMask: $objItem->{SuiteMask}\n"; print "SystemDevice: $objItem->{SystemDevice}\n"; print "SystemDirectory: $objItem->{SystemDirectory}\n"; print "SystemDrive: $objItem->{SystemDrive}\n"; print "TotalSwapSpaceSize: $objItem->{TotalSwapSpaceSize}\n"; print "TotalVirtualMemorySize: $objItem->{TotalVirtualMemorySize}\n"; print "TotalVisibleMemorySize: $objItem->{TotalVisibleMemorySize}\n"; print "Version: $objItem->{Version}\n"; print "WindowsDirectory: $objItem->{WindowsDirectory}\n"; print "\n"; } }sub WMIDateStringToDate(strDate) { return "blah"; }