Display pagefile (Perl)

This code can be found in Chapter 2 of Windows Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# This code displays the current page files on the system.
# ---------------------------------------------------------------
# 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;

# ------ SCRIPT CONFIGURATION ------
$strComputer = '.';
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colPF = $objWMI->InstancesOf('Win32_PageFileUsage');
foreach my $objPF (in $colPF) {
    print $objPF->Name, "\n";
    print '  Initial Size: ' . $objPF->AllocatedBaseSize, "\n";
    print '  Max Size: ' . $objPF->CurrentUsage, "\n";
    print '  Peak Usage: ' . $objPF->PeakUsage, "\n";
    print "\n";
}

This code has been viewed 766 times.

New from the creators of TechTasks.com: StatSheet.com