# This code prints system information similar to the systeminfo command.
# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
# "Windows Server Cookbook" by Robbie Allen
# ISBN: 0-596-00633-0
# ---------------------------------------------------------------
use Win32::OLE qw(in);
$Win32::OLE::Warn = 3;
use constant vbTab => "\x09";
# ------ SCRIPT CONFIGURATION ------
$strComputer = '.';
# e.g. rallen-srv01
# ------ END CONFIGURATION ---------
$dicProductType = Win32::OLE->new('Scripting.Dictionary');
$dicProductType->Add(1, 'Workstation');
$dicProductType->Add(2, 'Domain Controller');
$dicProductType->Add(3, 'Standalone Server');
$objWMIDateTime = Win32::OLE->new('WbemScripting.SWbemDateTime');
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colOS = $objWMI->InstancesOf('Win32_OperatingSystem');
foreach my $objOS (in $colOS) {
print 'Host Name: ' . $objOS->CSName, "\n";
print 'OS Name: ' . $objOS->Caption, "\n";
print 'OS Version: ' . $objOS->Version . ' Build ' . $objOS->BuildNumber, "\n";
print 'OS Manufacturer: ' . $objOS->Manufacturer, "\n";
print 'OS Configuration: ' . $dicProductType->Item($objOS->ProductType), "\n";
print 'OS Build Type: ' . $objOS->BuildType, "\n";
print 'Registered Owner: ' . $objOS->RegisteredUser, "\n";
print 'Registered Organization: ' . $objOS->Organization, "\n";
print 'Product ID: ' . $objOS->SerialNumber, "\n";
$objWMIDateTime->{Value} = $objOS->InstallDate;
print 'Original Install Date: ' . $objWMIDateTime->GetVarDate, "\n";
$objWMIDateTime->{Value} = $objOS->LastBootUpTime;
print 'System Up Time: ' . $objWMIDateTime->GetVarDate, "\n";
print 'Windows Directory: ' . $objOS->WindowsDirectory, "\n";
print 'System Directory: ' . $objOS->SystemDirectory, "\n";
print 'BootDevice: ' . $objOS->BootDevice, "\n";
print 'System Locale: ' . $objOS->Locale, "\n";
print 'Time Zone: ' . 'GMT' . $objOS->CurrentTimezone, "\n";
print 'Total Physical Memory: ' . sprintf("%.0f", $objOS->TotalVisibleMemorySize / 1024) . ' MB', "\n";
print 'Available Physical Memory: ' . sprintf("%.0f", $objOS->FreePhysicalMemory / 1024) . ' MB', "\n";
print 'Page File: Max Size: ' . sprintf("%.0f", $objOS->TotalVirtualMemorySize / 1024) . ' MB', "\n";
print 'Page File: Available: ' . sprintf("%.0f", $objOS->FreeVirtualMemory / 1024) . ' MB', "\n";
}
$colCS = $objWMI->InstancesOf('Win32_ComputerSystem');
foreach my $objCS (in $colCS) {
print 'System Manufacturer: ' . $objCS->Manufacturer, "\n";
print 'System Model: ' . $objCS->Model, "\n";
print 'System Type: ' . $objCS->SystemType, "\n";
print 'Domain: ' . $objCS->Domain, "\n";
print 'Processor(s): ' . $objCS->NumberofProcessors . ' Processor(s) Installed.', "\n";
}
$intCount = 0;
$colProcs = $objWMI->InstancesOf('Win32_Processor');
foreach my $objProc (in $colProcs) {
$intCount = $intCount + 1;
print vbTab . '[' . $intCount . ']: ' . $objProc->Caption . ' ~' . $objProc->MaxClockSpeed . 'Mhz', "\n";
}
$colBIOS = $objWMI->InstancesOf('Win32_BIOS');
foreach my $objBIOS (in $colBIOS) {
print 'BIOS Version: ' . $objBIOS->Version, "\n";
}
|