Display quota usage for users on a drive (Perl)

This code can be found in Chapter 7 of Windows XP 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.

# From the book, "Windows XP Cookbook"
# ISBN: 0596007256

# ------ SCRIPT CONFIGURATION ------

use Win32::OLE qw(in);

$strComputer = '.';
$strDrive = '<Drive>';
# e.g. D:
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colQuotas = $objWMI->ExecQuery('select * from Win32_DiskQuota ' . 'where QuotaVolume = \'Win32_LogicalDisk.DeviceID="' . $strDrive . '"\'');
foreach my $objQuota (in $colQuotas) {
    print 'User: ' . $objQuota->User, "\n";
    print ' Volume: ' . $objQuota->QuotaVolume, "\n";
    print ' Quota Limit: ' . $objQuota->Limit / 1024 / 1024 . 'MB', "\n";
    print ' Warning Limit: ' . $objQuota->WarningLimit / 1024 / 1024 . 'MB', "\n";
    print ' Disk Space Used: ' . $objQuota->DiskSpaceUsed / 1024 / 1024 . 'MB', "\n";
    print "\n";
}

This code has been viewed 918 times.

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