Recipe3.17.Viewing Disk Quota Usage


Recipe 3.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 3.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 selecting View 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 3.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.DeviceID=""" & 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 MS KB 320686 for more information on this issue.

    See Also

    Recipe 3.16, 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 Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

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