Recipe 7.17. Viewing Disk Quota Usage


Problem

You want to view the quota usage for one or more users.

Solution

Using a graphical user interface

  1. Open Windows Explorer.

  2. Browse to the drive on which you want to enable quotas, right-click it, and select Properties.

  3. Click the Quota tab.

  4. If quotas are enabled, click the Quota Entries button. If quotas are not enabled, enable them as described in Recipe 7.15.

  5. The Quota Entries application contains a listing of all users that have quotas configured along with their quota limit, warning limit, and amount used. You can sort this screen by select View Arrange Items from the menu and choosing one of the options to sort by.

Using a command-line interface

Use the following command to view the quota usage for all users on drive D:

> fsutil quota query d:

Use the following command to search the event log for all users that are violating their quota:

> fsutil quota violations

Before using the violations options of fsutil, be sure that you've enabled event logging of warning and limit errors (see Recipe 7.15).


Using VBScript
' This code displays the quota usage for users on a particular drive. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strDrive = "<Drive>"  ' e.g. D: ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colQuotas = objWMI.ExecQuery("select * from Win32_DiskQuota " & _      "where QuotaVolume = 'Win32_LogicalDisk.Device" & strDrive & """'") for each objQuota in colQuotas     WScript.Echo "User: "& objQuota.User     WScript.Echo "  Volume: "& objQuota.QuotaVolume     WScript.Echo "  Quota Limit: " & _                       objQuota.Limit / 1024 / 1024 & "MB"     WScript.Echo "  Warning Limit: " & _                       objQuota.WarningLimit / 1024 / 1024 & "MB"     WScript.Echo "  Disk Space Used: " & _                       objQuota.DiskSpaceUsed / 1024 / 1024 & "MB"     WScript.Echo "" next

Discussion

One of the nice features of the Quota Entries application is that you can drag-and-drop entries in it to a spreadsheet application like Excel. Simply highlight the entries you're interested in and drag them to Excel. You can also copy and paste them using Ctrl-C and Ctrl-V.

If you've enabled compression on a volume where quotas are also enabled, you may actually see quota usage increase compared to the same volume without compression.

See Also

Recipe 7.16 for enabling disk quotas for users; MS KB 307984, "HOW TO: Create Disk Quota Reports in Windows XP," MS KB 308664, "How To Export and Import Disk Quota Settings to Other Volumes in Windows XP," and MS KB 320686, "Disk Quota Charges Increase If You Turn On the NTFS Compression Functionality"



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net